当前位置: 代码迷 >> SQL >> 登录SQLPlus后对所做的操作都记要到文件中
  详细解决方案

登录SQLPlus后对所做的操作都记要到文件中

热度:55   发布时间:2016-05-05 13:57:15.0
登录SQLPlus后对所做的操作都记录到文件中

登录SQLPlus后对所做的操作都记录到文件中。利用Oracle中的Spool缓冲池技术做记录和备忘到文件里。

进入CMD命令行:
C:\Documents and Settings\sy>sqlplus /nolog

SQL*Plus: Release 10.1.0.2.0 - Production on 星期六 1月 15 21:09:42 2011

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

SQL> conn [email protected] as sysdba
Enter password:
Connected.
SQL> help spool

SPOOL
-----

Stores query results in a file, or optionally sends the file to a printer.
In iSQL*Plus, use the Preferences screen to direct output to a file.

SPO[OL] [file_name[.ext] [CRE[ATE] | REP[LACE] | APP[END]] | OFF | OUT]

Not available in iSQL*Plus

SQL> spool d:\outrecord.txt
SQL> desc DBA_FREE_SPACE
Name                                      Null?    Type
----------------------------------------- -------- ---------------------------

TABLESPACE_NAME                                    VARCHAR2(30)
FILE_ID                                            NUMBER
BLOCK_ID                                           NUMBER
BYTES                                              NUMBER
BLOCKS                                             NUMBER
RELATIVE_FNO                                       NUMBER

SQL> desc user_segments
Name                                      Null?    Type
----------------------------------------- -------- ---------------------------

SEGMENT_NAME                                       VARCHAR2(81)
PARTITION_NAME                                     VARCHAR2(30)
SEGMENT_TYPE                                       VARCHAR2(18)
TABLESPACE_NAME                                    VARCHAR2(30)
BYTES                                              NUMBER
BLOCKS                                             NUMBER
EXTENTS                                            NUMBER
INITIAL_EXTENT                                     NUMBER
NEXT_EXTENT                                        NUMBER
MIN_EXTENTS                                        NUMBER
MAX_EXTENTS                                        NUMBER
PCT_INCREASE                                       NUMBER
FREELISTS                                          NUMBER
FREELIST_GROUPS                                    NUMBER
BUFFER_POOL                                        VARCHAR2(7)

SQL> spool off


spool off关闭后,文件d:\outrecord.txt内容就写入了。

  相关解决方案