Oracle:spool 的一个用法

 

     spool 是sqlplus的一个语法,非sql。

 

平时,我们通过ssh或者xmanger连接到oracle后,如果我们想把我们在上面操作的脚本及脚本执行过程、结果保存下来的话,可以通过spool来实现。

 

sql>spool    /u01/1.log

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.

Total System Global Area 599785472 bytes
Fixed Size 2022632 bytes
Variable Size 197133080 bytes
Database Buffers 398458880 bytes
Redo Buffers 2170880 bytes
Database mounted.
Database opened.
SQL> select * from dictionary where rownum<4;

TABLE_NAME
------------------------------
COMMENTS
--------------------------------------------------------------------------------
ALL_XML_SCHEMAS
Description of all XML Schemas that user has privilege to reference

ALL_XML_SCHEMAS2
Dummy version of ALL_XML_SCHEMAS that does not have an XMLTYPE column

DBA_ROLES
All Roles which exist in the database

3 rows selected.

SQL> spool off

 

1.log中保存的内容就是上面内容。

 

该命令的好处:

1.可以记录操作过程

2.根据log,可以查看执行过程中的问题

 

 

你可能感兴趣的:(oracle)