I have to run several queries on an oracle 11g database
, within SQLDeveloper 3.1
.
For example:
select * from product;
select * from customer;
select * from prices;
At the moment I am exporting the resultsets "per hand", I simply right-click onto the result and then
export` it.
I would like to automatically save the resultset of each query in a specific folder.
Any recommendation how I could do that?
UPDATE
I tried using the csv
and als the txt
extesion of testFile
:
spool C:\Users\User\Desktop\testFile.csv --I tried also .txt extension here!!!
set colsep ';'
select * from product;
spool off;
However, when I open the file I get for csv and txt the following result:
> set colsep '
> select * from product
I appreciate your replies!
set echo off
set feedback off
set linesize 1000
set pagesize 0
set sqlprompt ''
set trimspool on
spool output.csv
select columnA || ',' || columnB || ',' || ......
from table
where ...
spool off;
exit 0;
Then create a shell script that calls the sql file
sqlplus >/dev/null 2>&1 "user/pass@DATABASE" << EOF
whenever sqlerror exit 1
@file.sql
EOF
UPDATE just saw you are on windows, same principle still applies, you probably will need to use PowerShell
You can use Spool, http://docs.oracle.com/cd/B19306_01/server.102/b14357/ch12043.htm
spool OutFile.txt
select row1||','||row2... from product; --format you prefer
spool off;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.