SET LIN 165;
SET PAGES 9999;
DEFINE _TBL_NAME = '&TABLE_NAME';
SELECT '-------------------------------' FROM DUAL;
SELECT '-- TABLE COMMENT --' FROM DUAL;
COL OWNER FORMAT A20;
COL TABLE_NAME FORMAT A30;
COL TABLE_TYPE FORMAT A20;
COL COMMENTS FORMAT A90;
SELECT DISTINCT OWNER, TABLE_NAME, TABLE_TYPE, COMMENTS
FROM DBA_TAB_COMMENTS
WHERE TABLE_NAME = UPPER('&_TBL_NAME')
ORDER BY OWNER, TABLE_NAME
;
SELECT '-- COLUMN COMMENT --' FROM DUAL;
COL OWNER FORMAT A20;
COL TABLE_NAME FORMAT A30;
COL COLUMN_NAME FORMAT A30;
COL COMMENTS FORMAT A80;
SELECT C.OWNER, C.TABLE_NAME, C.COLUMN_NAME, C.COMMENTS
FROM DBA_COL_COMMENTS C
INNER JOIN
DBA_TAB_COLUMNS T ON C.TABLE_NAME = T.TABLE_NAME
AND C.COLUMN_NAME = T.COLUMN_NAME
WHERE C.TABLE_NAME = UPPER('&_TBL_NAME')
ORDER BY C.OWNER, C.TABLE_NAME, T.COLUMN_ID
;
===========
查看单个字段
SET LIN 165;
SET PAGES 9999;
DEFINE _TBL_NAME = '&TABLE_NAME';
DEFINE _CLM_NAME = '&COLUMN_NAME';
SELECT '-- COLUMN COMMENT --' FROM DUAL;
COL OWNER FORMAT A20;
COL TABLE_NAME FORMAT A30;
COL COLUMN_NAME FORMAT A30;
COL COMMENTS FORMAT A80;
SELECT DISTINCT OWNER, TABLE_NAME, COLUMN_NAME, COMMENTS
FROM DBA_COL_COMMENTS
WHERE TABLE_NAME = UPPER('&_TBL_NAME')
AND COLUMN_NAME = UPPER('&_CLM_NAME')
ORDER BY OWNER, TABLE_NAME
;
===================
ddl_text
DEFINE _OBJ_NAME = '&OBJECT_NAME';
SET LIN 165;
SET PAGES 4000;
SET LONG 9000;
SELECT TEXT FROM USER_SOURCE T WHERE T.NAME = UPPER('&_OBJ_NAME') ORDER BY TYPE, LINE;