ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 在sqlplus下,用shell查询oracle,sql交互

在sqlplus下,用shell查询oracle,sql交互

原创 Linux操作系统 作者:os-ora 时间:2010-08-03 16:09:55 0 删除 编辑
[oracle@kook bin]$ cat test.sh
sqlplus -S "/ as sysdba" << !
select to_char(sysdate,'yyyy-mm-dd') today from dual;
exit;
!
执行结果
[oracle@test scrip]$ sh time.sh

TODAY
----------
2010-08-01

如果去掉S参数,执行结果如下
[oracle@test scrip]$ sh time.sh

SQL*Plus: Release 10.2.0.1.0 - Production on Sun Aug 1 16:08:59 2010

Copyright (c) 1982, 2005, Oracle.  All rights reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

SQL>
TODAY
----------
2010-08-01

SQL> Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
以上是去掉S参数的输出结果

还可以这样写
[oracle@kook bin]$ cat test.sh
sqlplus -S << !
conn / as sysdba
select to_char(sysdate,'yyyy-mm-dd') today from dual;
exit;
!
在用ftp命令时也有类似的对应参数“-n”.

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/16566331/viewspace-670106/ ,如需转载,请注明出处,否则将追究法律责任。

下一篇: 一个bonding的脚本
请登录后发表评论 登录
全部评论

注册时间:2010-01-12

  • 博文量
    148
  • 访问量
    410409