sqlplus 自动换行_sqlplus常用操作命令2

本文展示了如何在SQL环境中使用命令来管理缓冲区内容,包括列出、保存、读取和执行SQL语句。同时,还演示了如何将查询结果保存到文件以及从文件读取执行,最后通过spool命令将输出结果保存到文件并控制输出。
摘要由CSDN通过智能技术生成

SQL> list --列出缓冲区中的内容1 selectproduct_id,name,description2 from

3*products

SQL> save /home/oracle/test_save.sql --保存缓冲区中的内容到指定路径指定的文件中

Created file/home/oracle/test_save.sql

SQL> gettest_save.sql1 selectproduct_id,name,description2 from

3*products

SQL> start test_save.sql --将保存的文件内容读入缓冲区并执行

PRODUCT_ID NAME DESCRIPTION---------- ------------------------------ --------------------------------------------------

1Modern Science A description of modern science2Chemistry Introduction to Chemistry3Supernova A star explodes4Tank War Action movie about a future war5Z Files Series on mysterious activities6 2412: The Return Aliens return

7 Space Force 9Adventures of heroes8 From Another Planet Alien fromanother planet lands on Earth9Classical Music The best classical music10 Pop 3The best popular music11Creative Yell Debut album12My Front Line Their greatest hits12rows selected.

SQL> @test_save.sql --同start

PRODUCT_ID NAME DESCRIPTION---------- ------------------------------ --------------------------------------------------

1Modern Science A description of modern science2Chemistry Introduction to Chemistry3Supernova A star explodes4Tank War Action movie about a future war5Z Files Series on mysterious activities6 2412: The Return Aliens return

7 Space Force 9Adventures of heroes8 From Another Planet Alien fromanother planet lands on Earth9Classical Music The best classical music10 Pop 3The best popular music11Creative Yell Debut album12My Front Line Their greatest hits12rows selected.

SQL> spool /home/oracle/select.txt --将以下输出的结果保存到指定文件中

SQL> /PRODUCT_ID NAME DESCRIPTION---------- ------------------------------ --------------------------------------------------

1Modern Science A description of modern science2Chemistry Introduction to Chemistry3Supernova A star explodes4Tank War Action movie about a future war5Z Files Series on mysterious activities6 2412: The Return Aliens return

7 Space Force 9Adventures of heroes8 From Another Planet Alien fromanother planet lands on Earth9Classical Music The best classical music10 Pop 3The best popular music11Creative Yell Debut album12My Front Line Their greatest hits12rows selected.

SQL> spool off --停止输出结果,并关闭该文件,如果不spoo off,则后面输入的所有结果都会写入到上面的select.txt文件

SQL>[root@rhel201 oracle]# ls

afiedt.buf oradiag_oracleselect.txt testbak test_save.sql test.sql

[root@rhel201 oracle]# cat test_save.sqlselectproduct_id,name,descriptionfromproducts/[root@rhel201 oracle]# catselect.txt

SQL> /PRODUCT_ID NAME DESCRIPTION---------- ------------------------------ --------------------------------------------------

1Modern Science A description of modern science2Chemistry Introduction to Chemistry3Supernova A star explodes4Tank War Action movie about a future war5Z Files Series on mysterious activities6 2412: The Return Aliens return

7 Space Force 9Adventures of heroes8 From Another Planet Alien fromanother planet lands on Earth9Classical Music The best classical music10 Pop 3The best popular music11Creative Yell Debut album12My Front Line Their greatest hits12rows selected.

SQL>spool off

[root@rhel201 oracle]#

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值