首頁 >資料庫 >mysql教程 >Oracle用SQL语句实现desc函数功能

Oracle用SQL语句实现desc函数功能

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB原創
2016-06-07 16:46:441981瀏覽

Oracle用SQL语句实现desc函数功能: SELECT A.COLUMN_NAME 字段名, DATA_TYPE ||DECODE(DATA_TYPE,

Oracle用SQL语句实现desc函数功能

[日期:2012-05-18] 来源:Linux社区  作者:Linux [字体:]

Oracle用SQL语句实现desc函数功能:

SELECT A.COLUMN_NAME 字段名,
        DATA_TYPE ||DECODE(DATA_TYPE,'DATE','','CLOB','','BLOB','','BFILE','','FLOAT','','LONG RAW','','LONG','','RAW','(' || TO_CHAR(DATA_LENGTH) || ')',
               (DECODE(SIGN(INSTR(DATA_TYPE, 'CHAR')),1,
                 '(' || TO_CHAR(DATA_LENGTH) || ')',(DECODE(SUBSTR(DATA_TYPE, 1, 9),
                  'TIMESTAMP', '',
                 (DECODE(NVL(DATA_PRECISION, -1), -1,
                  '',(DECODE(NVL(DATA_SCALE, 0), 0,
                  '(' || TO_CHAR(DATA_PRECISION) || ')', '(' || TO_CHAR(DATA_PRECISION) || ',' ||
                 TO_CHAR(DATA_SCALE) || ')'))))))))) 字段类型,
        A.NULLABLE 允许为空,
        A.DATA_DEFAULT 默认值,
        B.COMMENTS 字段注释
   FROM ALL_TAB_COLUMNS A,
        ALL_COL_COMMENTS B
  WHERE B.TABLE_NAME=A.TABLE_NAME
  AND A.OWNER=B.OWNER
  AND A.COLUMN_NAME=B.COLUMN_NAME
  AND A.TABLE_NAME =UPPER( 'TABLE_NAME')
    AND A.OWNER =UPPER( 'USER')
  ORDER BY COLUMN_ID;

更多Oracle相关信息见Oracle 专题页面 ?tid=12

linux

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn