oracle 我想将unix和sqlplus的输出复制到一个文件中
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2467573/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
I want to copy the output of unix and sqlplus into a file
提问by randeepsp
I am using Solaris. I have to log into sql plus and run some queries, which give a huge result set.
我正在使用 Solaris。我必须登录 sql plus 并运行一些查询,这会给出一个巨大的结果集。
I want to copy all that into a file. Is there any command for it in unix or sqlplus ?
我想将所有这些复制到一个文件中。在 unix 或 sqlplus 中是否有任何命令?
回答by OMG Ponies
Use the SPOOL
command:
使用SPOOL
命令:
SQL> SPOOL /opt/output
SQL> SELECT ...
SQL> SPOOL OFF
回答by Stellios
setup Oracle environment
设置 Oracle 环境
(there are ways around specifying username/password on the command line - not the best way especially when other users can 'ps' on the server and see your password)
(有一些方法可以在命令行上指定用户名/密码 - 不是最好的方法,尤其是当其他用户可以在服务器上“ps”并查看您的密码时)
sqlplus -s username/password <<-!!
set trimspool on trimout on pages 0 feedback off linesize 1000 echo off verify off
spool file.out
select sysdate from dual;
exit
!!
回答by zellio
If you are on the command line then just use the > and 2> to redirect stdout and stderr respectively to log files
如果您在命令行上,则只需使用 > 和 2> 将 stdout 和 stderr 分别重定向到日志文件
func > out.log
func > out.log