SELECT A1.TABLE_NAME TABLE_NAME
, A1.TABLE_COMMENTS TABLE_COMMENTS
, A1.COLUMN_NAME COLUMN_NAME
, A1.COLUMN_COMMENTS COLUMN_COMMENTS
, A1.DATA_TYPE
, A1.DATA_LENGTH
, (SELECT DECODE(COUNT(B.CONSTRAINT_TYPE), 0, 'N', 'Y')
FROM USER_CONS_COLUMNS A
, USER_CONSTRAINTS B
WHERE (A.CONSTRAINT_NAME = B.CONSTRAINT_NAME)
AND B.CONSTRAINT_TYPE = 'P'
AND A.TABLE_NAME = A1.TABLE_NAME
AND A.COLUMN_NAME = A1.COLUMN_NAME) AS PK_FLAG
, (SELECT DECODE(COUNT(B.CONSTRAINT_TYPE), 0, 'N', 'Y')
FROM USER_CONS_COLUMNS A
, USER_CONSTRAINTS B
WHERE (A.CONSTRAINT_NAME = B.CONSTRAINT_NAME)
AND B.CONSTRAINT_TYPE = 'R'
AND A.TABLE_NAME = A1.TABLE_NAME
AND A.COLUMN_NAME = A1.COLUMN_NAME) AS FK_FLAG
, A1.NOT_NULL
FROM (SELECT B.COMMENTS TABLE_COMMENTS
, A.TABLE_NAME TABLE_NAME
, C.COMMENTS COLUMN_COMMENTS
, A.COLUMN_NAME COLUMN_NAME
, DECODE(A.NULLABLE,'Y','N','N','Y') AS NOT_NULL
, A.DATA_TYPE AS DATA_TYPE
, DECODE(A.DATA_TYPE ,'DATE' ,'' , 'NUMBER',DECODE(A.DATA_SCALE, '0' ,A.DATA_PRECISION , '' ) , A.DATA_LENGTH ) AS DATA_LENGTH
, A.COLUMN_ID
FROM USER_TAB_COLUMNS A
, USER_TAB_COMMENTS B
, USER_COL_COMMENTS C
WHERE A.TABLE_NAME = '테이블명 대문자'
AND (A.TABLE_NAME = B.TABLE_NAME)
AND ( A.TABLE_NAME = C.TABLE_NAME
AND A.COLUMN_NAME = C.COLUMN_NAME
)) A1
ORDER BY A1.TABLE_NAME, A1.COLUMN_ID
;