SELECT A1.TABLE_COMMENTS TABLE_COMMENTS
, A1.TABLE_NAME TABLE_NAME
, A1.COLUMN_COMMENTS COLUMN_COMMENTS
, A1.COLUMN_NAME COLUMN_NAME
, (CASE
WHEN B1.CONSTRAINT_TYPE = 'P'
THEN 'Y'
END) PK_FLAG
, (CASE
WHEN B1.CONSTRAINT_TYPE = 'R'
THEN 'Y'
END) FK_FLAG
, A1.NULL_FLAG
, A1.DATA_TYPE
, A1.DATA_LENGTH
FROM (SELECT B.COMMENTS TABLE_COMMENTS
, A.TABLE_NAME TABLE_NAME
, C.COMMENTS COLUMN_COMMENTS
, A.COLUMN_NAME COLUMN_NAME
, (CASE A.NULLABLE
WHEN 'Y'
THEN 'Y'
END) NULL_FLAG
, A.DATA_TYPE DATA_TYPE
, (CASE
WHEN A.DATA_TYPE IN ('CHAR', 'VARCHAR2')
THEN '(' || A.DATA_LENGTH || ')'
WHEN A.DATA_TYPE = 'NUMBER'
AND A.DATA_SCALE = 0
AND A.DATA_PRECISION IS NOT NULL
THEN '(' || A.DATA_PRECISION || ')'
WHEN A.DATA_TYPE = 'NUMBER'
AND A.DATA_SCALE <> 0
THEN '(' || A.DATA_PRECISION || ',' || A.DATA_SCALE
|| ')'
END
) DATA_LENGTH
, A.COLUMN_ID
FROM USER_TAB_COLUMNS A
, USER_TAB_COMMENTS B
, USER_COL_COMMENTS C
WHERE (A.TABLE_NAME = B.TABLE_NAME)
AND ( A.TABLE_NAME = C.TABLE_NAME
AND A.COLUMN_NAME = C.COLUMN_NAME
)) A1
, (SELECT A.TABLE_NAME
, A.COLUMN_NAME
, B.CONSTRAINT_TYPE
FROM USER_CONS_COLUMNS A
, USER_CONSTRAINTS B
WHERE (A.CONSTRAINT_NAME = B.CONSTRAINT_NAME)
AND B.CONSTRAINT_TYPE IN ('P', 'R')) B1
WHERE ( A1.TABLE_NAME = B1.TABLE_NAME(+)
AND A1.COLUMN_NAME = B1.COLUMN_NAME(+))
ORDER BY A1.TABLE_NAME, A1.COLUMN_ID
'프로그래밍 > 데이터베이스' 카테고리의 다른 글
[오라클] 비밀번호 관리 (0) | 2023.03.06 |
---|---|
[오라클] 리눅스에서 한글 설정 (0) | 2023.03.06 |
[오라클] Windows7 에서 오라클 10g Client 설치하기 (0) | 2023.03.06 |
[MSSQL] Lock 조회 및 해결 방법 (0) | 2023.03.06 |
[ERWin] DB 접속시 오류 발생시 처리 방법 (0) | 2023.03.06 |
댓글