<
Shell中重定向<
1.EOF也可以换成其他任意的字符,大小写不论,只要成对出现即可
2. 第二个EOF必须顶格写,否则会报错。
3. EOF中如果带有 $变量的时候会将$和变量名变成空格
如果不希望EOF中的$符号不希望被当成默认的转义字符需改成\$
sqlplus -S /nolog <
connect / as sysdba;
set heading off;
set feedback off;
set echo off;
set pagesize 800;
set line 450;
set echo off;
set veri off;
spool /tmp/status.log;
select decode(status,'OPEN',0,2) "status" from v\$instance;
spool off;
exit;
EOF
======================问题:=====================================================
[oracle@ORACLE-master ~]$
[oracle@ORACLE-master ~]$ sqlplus -S /nolog <
> connect / as sysdba;
> set heading off;
> set feedback off;
> set echo off;
> set pagesize 800;
> set line 450;
> set echo off;
> set veri off;
> spool /tmp/status.log;
> select decode(status,'OPEN',0,2) "status" from v$instance;
> spool off;
> exit;
> EOF
select decode(status,'OPEN',0,2) "status" from v
*
ERROR at line 1:
ORA-00942: table or view does not exist
[oracle@ORACLE-master ~]$
==============正确=========================================
[oracle@ORACLE-master ~]$ sqlplus -S /nolog <
> connect / as sysdba;
> set heading off;
> set feedback off;
> set echo off;
> set pagesize 800;
> set line 450;
> set echo off;
> set veri off;
> spool /tmp/status.log;
> select decode(status,'OPEN',0,2) "status" from v\$instance;
> spool off;
> exit;
> EOF
0
Shell中重定向<
1.EOF也可以换成其他任意的字符,大小写不论,只要成对出现即可
2. 第二个EOF必须顶格写,否则会报错。
3. EOF中如果带有 $变量的时候会将$和变量名变成空格
如果不希望EOF中的$符号不希望被当成默认的转义字符需改成\$
sqlplus -S /nolog <
connect / as sysdba;
set heading off;
set feedback off;
set echo off;
set pagesize 800;
set line 450;
set echo off;
set veri off;
spool /tmp/status.log;
select decode(status,'OPEN',0,2) "status" from v\$instance;
spool off;
exit;
EOF
======================问题:=====================================================
[oracle@ORACLE-master ~]$
[oracle@ORACLE-master ~]$ sqlplus -S /nolog <
> connect / as sysdba;
> set heading off;
> set feedback off;
> set echo off;
> set pagesize 800;
> set line 450;
> set echo off;
> set veri off;
> spool /tmp/status.log;
> select decode(status,'OPEN',0,2) "status" from v$instance;
> spool off;
> exit;
> EOF
select decode(status,'OPEN',0,2) "status" from v
*
ERROR at line 1:
ORA-00942: table or view does not exist
[oracle@ORACLE-master ~]$
==============正确=========================================
[oracle@ORACLE-master ~]$ sqlplus -S /nolog <
> connect / as sysdba;
> set heading off;
> set feedback off;
> set echo off;
> set pagesize 800;
> set line 450;
> set echo off;
> set veri off;
> spool /tmp/status.log;
> select decode(status,'OPEN',0,2) "status" from v\$instance;
> spool off;
> exit;
> EOF
0
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/8494287/viewspace-1418058/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/8494287/viewspace-1418058/