5. 关闭spool输出 SQL> SPOOL OFF 只有关闭spool输出,才会在输出文件中看到输出的内容。
6.显示一个表的结构 SQL> desc table_name
7. COL命令: 主要格式化列的显示形式。 该命令有许多选项,具体如下: COL[UMN] [{ column|expr} [ option ...]] Option选项可以是如下的子句: ALI[AS] alias CLE[AR] FOLD_A[FTER] FOLD_B[EFORE] FOR[MAT] format HEA[DING] text JUS[TIFY] {L[EFT]|C[ENTER]|C[ENTRE]|R[IGHT]} LIKE { expr|alias} NEWL[INE] NEW_V[ALUE] variable NOPRI[NT]|PRI[NT] NUL[L] text OLD_V[ALUE] variable ON|OFF WRA[PPED]|WOR[D_WRAPPED]|TRU[NCATED]
1). 改变缺省的列标题 COLUMN column_name HEADING column_heading For example: Sql>select * from dept; DEPTNO DNAME LOC ---------- ---------------------------- --------- 10 ACCOUNTING NEW YORK sql>col LOC heading location sql>select * from dept; DEPTNO DNAME location --------- ---------------------------- ----------- 10 ACCOUNTING NEW YORK
2). 将列名ENAME改为新列名EMPLOYEE NAME并将新列名放在两行上: Sql>select * from emp Department name Salary ---------- ---------- ---------- 10 aaa 11 SQL> COLUMN ENAME HEADING ’Employee|Name’ Sql>select * from emp Employee Department name Salary ---------- ---------- ---------- 10 aaa 11 note: the col heading turn into two lines from one line.
3). 改变列的显示长度: FOR[MAT] format Sql>select empno,ename,job from emp; EMPNO ENAME JOB ---------- ---------- --------- 7369 SMITH CLERK 7499 ALLEN SALESMAN 7521 WARD SALESMAN Sql> col ename format a40 EMPNO ENAME JOB ---------- ---------------------------------------- --------- 7369 SMITH CLERK 7499 ALLEN SALESMAN 7521 WARD SALESMAN
4). 设置列标题的对齐方式 JUS[TIFY] {L[EFT]|C[ENTER]|C[ENTRE]|R[IGHT]} SQL> col ename justify center SQL> / EMPNO ENAME JOB ---------- ---------------------------------------- --------- 7369 SMITH CLERK 7499 ALLEN SALESMAN 7521 WARD SALESMAN 对于NUMBER型的列,列标题缺省在右边,其它类型的列标题缺省在左边
5). 不让一个列显示在屏幕上 NOPRI[NT]|PRI[NT] SQL> col job noprint SQL> / EMPNO ENAME ---------- ---------------------------------------- 7369 SMITH 7499 ALLEN 7521 WARD
6). 格式化NUMBER类型列的显示: SQL> COLUMN SAL FORMAT $99,990 SQL> / Employee Department Name Salary Commission ---------- ---------- --------- ---------- 30 ALLEN $1,600 300
7). 显示列值时,如果列值为NULL值,用text值代替NULL值 COMM NUL[L] text SQL>COL COMM NUL[L] text
8). 设置一个列的回绕方式 WRA[PPED]|WOR[D_WRAPPED]|TRU[NCATED] COL1 -------------------- HOW ARE YOU?
SQL>COL COL1 FORMAT A5 SQL>COL COL1 WRAPPED COL1 ----- HOW A RE YO U?
SQL> COL COL1 WORD_WRAPPED COL1 ----- HOW ARE YOU?
SQL> COL COL1 WORD_WRAPPED COL1 ----- HOW A
9). 显示列的当前的显示属性值 SQL> COLUMN column_name
10). 将所有列的显示属性设为缺省值 SQL> CLEAR COLUMNS
8. 屏蔽掉一个列中显示的相同的值 BREAK ON break_column SQL> BREAK ON DEPTNO SQL> SELECT DEPTNO, ENAME, SAL FROM EMP WHERE SAL < 2500 ORDER BY DEPTNO; DEPTNO ENAME SAL ---------- ----------- --------- 10 CLARK 2450 MILLER 1300 20 SMITH 800 ADAMS 1100
9. 在上面屏蔽掉一个列中显示的相同的值的显示中,每当列值变化时在值变化之前插入n个空行。 BREAK ON break_column SKIP n
SQL> BREAK ON DEPTNO SKIP 1 SQL> / DEPTNO ENAME SAL ---------- ----------- --------- 10 CLARK 2450 MILLER 1300
Sql>PAUSE Adjust paper and press RETURN to continue.
29.将一个数据库中的一些数据拷贝到另外一个数据库(如将一个表的数据拷贝到另一个数据库) COPY {FROM database | TO database | FROM database TO database} {APPEND|CREATE|INSERT|REPLACE} destination_table [(column, column, column, ...)] USING query
sql>COPY FROM SCOTT/TIGER@HQ TO JOHN/CHROME@WEST create emp_temp USING SELECT * FROM EMP
32.显示sql*plus命令的帮助 HELP 如何安装帮助文件: Sql>@ ?\sqlplus\admin\help\hlpbld.sql ?\sqlplus\admin\help\helpus.sql Sql>help index
33.显示sql*plus系统变量的值或sql*plus环境变量的值 Syntax SHO[W] option where option represents one of the following terms or clauses: system_variable ALL BTI[TLE] ERR[ORS] [{FUNCTION|PROCEDURE|PACKAGE|PACKAGE BODY| TRIGGER|VIEW|TYPE|TYPE BODY} [schema.]name] LNO PARAMETERS [parameter_name] PNO REL[EASE] REPF[OOTER] REPH[EADER] SGA SPOO[L] SQLCODE TTI[TLE] USER
1) . 显示当前环境变量的值: Show all
2) . 显示当前在创建函数、存储过程、触发器、包等对象的错误信息 Show error 当创建一个函数、存储过程等出错时,变可以用该命令查看在那个地方出错及相应的出错信息,进行修改后再次进行编译。