'how to save oracle SQL queries automatically when a query is executed?
I want to save SQL/PLSQL queries, which are being executed by a user.
I use the below, and have to use append
at the end of the statement as well as saving at the beginning. But, it's headache to execute a save statement all the time after a query is executed.
I'd like to know if there is there any command that would automatically save the queries to the file.
SQL> save C:\savesueryfolder\first.sql;
SQL> select * from emp;
SQL> save C:\savesueryfolder\first.sql append;
Solution 1:[1]
Try for SPOOL command. SPOOL command save the output into a file. you can apply following steps-
STEP 1:
Provide the location where you want to spool the output.
sql> SPOOL C:\Users\Anant\Desktop\temp.text
(or temp.doc depends with which extension you want to save.I recommend to go for.doc)
If temp.doc/temp.txt
is already available then it just override the file, so be careful always try to create a new file.
STEP 2:
execute queries .
sql> SELECT * FROM EMP;
You can execute any number of queries.
STEP 3:
close the spool.
sql>SPOOL OFF
go to specified location and check the file.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | madlymad |