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]#