数据库数据字典表查询:
SELECT
COL.TABLE_NAME,
TT.COMMENTS,
COL.COLUMN_NAME AS COLUMNNAME,
CASE
WHEN PKCOL.COLUMN_POSITION > 0 THEN
'√'
ELSE
''
END AS ISPK,
COL.DATA_TYPE AS TYPENAME,
COL.DATA_LENGTH 占用字节数,
COL.DATA_PRECISION AS PRECI,
COL.DATA_SCALE AS SCALE,
CASE
WHEN COL.NULLABLE = 'Y' THEN
'√'
ELSE
''
END AS CISNULL,
COL.DATA_DEFAULT AS DEFAULTVAL,
CCOM.COMMENTS AS DETEXT
FROM
USER_TAB_COLUMNS COL,
USER_COL_COMMENTS CCOM,
(SELECT AA.TABLE_NAME,
AA.INDEX_NAME,
AA.COLUMN_NAME,
AA.COLUMN_POSITION
FROM USER_IND_COLUMNS AA, USER_CONSTRAINTS BB
WHERE BB.CONSTRAINT_TYPE = 'P'
AND AA.TABLE_NAME = BB.TABLE_NAME
AND AA.INDEX_NAME = BB.CONSTRAINT_NAME
) PKCOL,
USER_TAB_COMMENTS TT
WHERE COL.TABLE_NAME = CCOM.TABLE_NAME
AND COL.COLUMN_NAME = CCOM.COLUMN_NAME
AND COL.TABLE_NAME = TT.TABLE_NAME(+)
AND COL.COLUMN_NAME = PKCOL.COLUMN_NAME(+)
AND COL.TABLE_NAME = PKCOL.TABLE_NAME(+)
ORDER BY COL.TABLE_NAME,col.column_id;