加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

使用批处理文件访问ORACLE数据库

发布时间:2020-12-12 13:23:30 所属栏目:百科 来源:网络整理
导读:新建txt文件编写代码: sqlplus c##scott/tiger @runsql.sql 用户名c##scott 密码tiger 将文件后缀改为.bat 新建txt文件编写,文件名为runsql 编写代码 1 conn c##scott / tiger 2 -- 写你的sql语句 3 select * from ( select * from dept order by rownum)

新建txt文件编写代码:

sqlplus c##scott/tiger @runsql.sql

用户名c##scott

密码tiger

将文件后缀改为.bat

新建txt文件编写,文件名为runsql

编写代码

1 conn c##scott/tiger
2 --写你的sql语句
3 select * from (select * from dept order by rownum) where rownum<2;
4 commit;
5 pause;
6 exit;

将文件名改为runsql.sql

执行.bat文件即可

如果需要将结果输出到文本文件的话,利用spool缓冲池

1 conn c##scott/tiger
2 spool d:output.txt
3 select * from (select * from dept order by rownum) where rownum<2;
4 commit;
5 spool off;
6 pause;
7 exit;

?spool d:output.txt 指定输出的路径和文件

最后输入缓冲结果命令

spool off;?

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读