srikanthradix
asked on
Spool Query in Oracle
How to spool the output of an sql query into a CSV file?
select * from table1 group by column1;
And the select statement should not print anything to the System Out. How to do that?
select * from table1 group by column1;
And the select statement should not print anything to the System Out. How to do that?
if you have toad, you can execute the query and give mouse click and save as "you can find one of the option for saving it as csv file".
if you want to do it in sql*plus, then save the below in a testing.sql file and run it from sqlplus prompt
set echo off -- this is to ensure that sql statement is not printed in the spool file
set feedback off
spool output.csv -- to create a file named output.csv
select * from table1 group by column1;
spool off
set echo on
set feedback on
if you want to do it in sql*plus, then save the below in a testing.sql file and run it from sqlplus prompt
set echo off -- this is to ensure that sql statement is not printed in the spool file
set feedback off
spool output.csv -- to create a file named output.csv
select * from table1 group by column1;
spool off
set echo on
set feedback on
ASKER
Hi everyone,
I am using SQL Plus Worksheet & Oracle SQL Developer, it is spooling to the CSV file & still printing it to the output
I am using SQL Plus Worksheet & Oracle SQL Developer, it is spooling to the CSV file & still printing it to the output
The sqlplus "set" options doesnt work from the SQL Developer screen.
You have to use the "sqlplus" tool itself for that.
You have to use the "sqlplus" tool itself for that.
select * from table1 group by column1;
put this sql statement in a file for eg: a.sql
Set echo off;
Set define Off;
Set feedback Off;
Set serveroutput On;
SET PAGESIZE 0
SET LINESIZE 1000
Spool results.log
start a.sql;
Spool Off;
Set define On;
Set feedback On;
put this sql statement in a file for eg: a.sql
Set echo off;
Set define Off;
Set feedback Off;
Set serveroutput On;
SET PAGESIZE 0
SET LINESIZE 1000
Spool results.log
start a.sql;
Spool Off;
Set define On;
Set feedback On;
ASKER
Set echo off;
Set define Off;
Set feedback Off;
Set serveroutput On;
SET PAGESIZE 0
SET LINESIZE 1000
Spool c:/results.log
start c:/stmt.sql;
Spool Off;
Set define On;
Set feedback On;
It is writing to file. But, Still writing to output screen.
Set define Off;
Set feedback Off;
Set serveroutput On;
SET PAGESIZE 0
SET LINESIZE 1000
Spool c:/results.log
start c:/stmt.sql;
Spool Off;
Set define On;
Set feedback On;
It is writing to file. But, Still writing to output screen.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Set define Off;
Set feedback Off;
Set serveroutput On;
SET PAGESIZE 0
SET LINESIZE 1000
Spool results.log
select * from table1 group by column1;
Spool Off;
Set define On;
Set feedback On;