테이블 정의를 출력해주는 쿼리
SQL> SELECT TC.TABLE_NAME
,TCOMMENT.COMMENTS AS KOR_TNAME
,TC.COLUMN_NAME
,CCOMMENT.COMMENTS AS KOR_CNAME
,TC.DATA_TYPE||'('||TC.DATA_LENGTH||')'
,DECODE(PK.CT,'P','PK','') AS PK
,DECODE(TC.NULLABLE,'N','NOT NULL','') AS NOT_NULL
,TC.DATA_DEFAULT,'' AS ETC
FROM USER_TAB_COLUMNS TC
,USER_COL_COMMENTS CCOMMENT
,USER_TAB_COMMENTS TCOMMENT
,(
SELECT CCOL.TABLE_NAME,CCOL.COLUMN_NAME,UC.CONSTRAINT_TYPE CT
FROM USER_CONS_COLUMNS CCOL,USER_CONSTRAINTS UC
WHERE CCOL.CONSTRAINT_NAME = UC.CONSTRAINT_NAME
AND CCOL.TABLE_NAME = UC.TABLE_NAME
AND UC.CONSTRAINT_TYPE = 'P'
) PK
WHERE TC.TABLE_NAME = TCOMMENT.TABLE_NAME
AND TC.TABLE_NAME = CCOMMENT.TABLE_NAME
AND TC.COLUMN_NAME = CCOMMENT.COLUMN_NAME
AND TC.TABLE_NAME = PK.TABLE_NAME(+)
AND TC.COLUMN_NAME = PK.COLUMN_NAME(+)
AND TC.TABLE_NAME LIKE 'TB_%' AND TC.TABLE_NAME NOT LIKE '%_HIST'
AND TCOMMENT.TABLE_TYPE = 'TABLE'
ORDER BY TC.TABLE_NAME,TC.COLUMN_ID;