How to output oracle sql result into a file in windows?

后端 未结 5 677
旧时难觅i
旧时难觅i 2020-12-13 13:32

I tried

select * from users 
save D:\\test.sql create;

But SQL plus gives me \"no proper ended\" How to specify path in oracle sql in windo

5条回答
  •  暖寄归人
    2020-12-13 14:26

    Use the spool:

    spool myoutputfile.txt
    select * from users;
    spool off;
    

    Note that this will create myoutputfile.txt in the directory from which you ran SQL*Plus.

    If you need to run this from a SQL file (e.g., "tmp.sql") when SQLPlus starts up and output to a file named "output.txt":

    tmp.sql:

    select * from users;
    

    Command:

    sqlplus -s username/password@sid @tmp.sql > output.txt
    

    Mind you, I don't have an Oracle instance in front of me right now, so you might need to do some of your own work to debug what I've written from memory.

提交回复
热议问题