How to use spool command in sql developer oracle

2019-08-06 04:40发布

问题:

Dears, I cannot use spool command. It is not working or i am not doing something right. I am trying to save query result in txt file (tried also csv saving with select /*csv*/ * from table but it also did not work).

So what i wrote is:

set echo off
set trimspool on
spool 'C:\Users\username\Desktop\clobams\Test1.txt'
select  pn, serial_number from stock ;
spool off;

And i am getting error when pressing execute statement ORA-00900:invalid SQL statement . Sql works fine - when i execute only that part,it gives me output to the screen. How should i save my output to the file?

I have already tried to remove set echo off and set trimspool on but none of these helped

回答1:

this is what i have run on my sql developer:

spool C:\Users\**direcotory**\Desktop\old desktop\sql\Test1.txt;
select  *  from YOUR_TABLE;
spool off;

and i got output in file test1. you need to run all commands as script.