COL命令用法

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        

你可能感兴趣的:(oracle)