September 29 2015

oracle col option

ORALCE COL OPTION

SQL> help column
 COLUMN
 ——
 Specifies display attributes for a given column, such as:
     – text for the column heading
     – alignment for the column heading
     – format for NUMBER data
     – wrapping of column data
 Also lists the current display attributes for a single column
 or all columns.
 COL[UMN] [{column | expr} [option …] ]
 where option represents one of the following clauses:
     ALI[AS] alias
     CLE[AR]
     ENTMAP {ON|OFF}
     FOLD_A[FTER]
     FOLD_B[EFORE]
     FOR[MAT] format
     HEA[DING] text
     JUS[TIFY] {L[EFT] | C[ENTER] | 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]
改变列的缺省名
SQL> col last_name heading lname
SQL> select * from cust_payment_infor;
First    lname       Order# CREDIT_CARD_NUMBER   ACT
——– ———- ——- ——————– —
Jon      Oldfield     10001 54469709912985       YES
Chris    White        10002 5122358046082560     YES
将列名last_name改为新列名last NAME并将新列名放在两行上:
SQL> col last_name heading ‘LAST|NAME’
SQL> select * from cust_payment_infor;
           LAST
First    NAME        Order# CREDIT_CARD_NUMBER   ACT
——– ———- ——- ——————– —
Jon      Oldfield     10001 54469709912985       YES
Chris    White        10002 5122358046082560     YES
改变列的显示长度:
SQL> col first_name for a8 head ‘First’
SQL> col order_number for 999999 head ‘Order#’
SQL> select * from cust_payment_infor;
First    LAST_NAME   Order# CREDIT_CARD_NUMBER   ACT
——– ———- ——- ——————– —
Jon      Oldfield     10001 54469709912985       YES
Chris    White        10002 5122358046082560     YES
设置列标题的对齐方式
 SQL> col first_name justify center
JUS[TIFY] {L[EFT] | C[ENTER] | R[IGHT]}
SQL> select * from cust_payment_infor;
         LAST
 First   NAME        Order# CREDIT_CARD_NUMBER   ACT
——– ———- ——- ——————– —
Jon      Oldfield     10001 54469709912985       YES
Chris    White        10002 5122358046082560     YES
 5). 不让一个列显示在屏幕上

NOPRI[NT]|PRI[NT]

SQL> COL CREDIT_CARD_NUMBER NOPRI
SQL> SELECT * FROM cust_payment_infor;
         LAST
 First   NAME        Order# ACT
——– ———- ——- —
Jon      Oldfield     10001 YES
Chris    White        10002 YES
显示列值时,如果列值为NULL值,用text值代替NULL值
COMM NUL[L] text
SQL>COL COMM NUL[L] text
显示列的当前的显示属性值
SQL> COLUMN LAST_NAME
COLUMN   last_name ON
HEADING  ‘LAST|NAME’ headsep ‘|’
将所有列的显示属性设为缺省值
SQL> CLEAR COLUMNS


Copyright 2019. All rights reserved.

Posted 2015年9月29日 by ucjmh in category "oracle

Leave a Reply

Your email address will not be published. Required fields are marked *