헤르메스 LIFE

[Oracle] 테이블 정보 조회 + Camel 표기 본문

Database

[Oracle] 테이블 정보 조회 + Camel 표기

헤르메스의날개 2020. 11. 24. 00:40
728x90

테이블 정보( 테이블 Comment + 컬럼 Comment + PK ) + Camel 표기

SELECT A.COLUMN_NAME
,      SUBSTR(LOWER(A.COLUMN_NAME), 1,1) || SUBSTR(REPLACE(INITCAP(A.COLUMN_NAME), '_'), 2)  AS INIT_COL_CAP_NAME
,      B.COMMENTS
,      CASE WHEN LENGTH(C.INDEX_NAME) > 0 THEN 'PK' ELSE '' END AS PK_DIV
,      D.COMMENTS TABLE_COMMENTS
FROM   ALL_TAB_COLUMNS    A
,      ALL_COL_COMMENTS   B
,      ALL_IND_COLUMNS    C
,      ALL_TAB_COMMENTS   D
WHERE  A.TABLE_NAME  = B.TABLE_NAME
AND    A.COLUMN_NAME = B.COLUMN_NAME
AND    A.OWNER       = B.OWNER
AND    A.TABLE_NAME  = C.TABLE_NAME(+)
AND    A.COLUMN_NAME = C.COLUMN_NAME(+)
AND    A.OWNER       = C.INDEX_OWNER(+)
AND    A.OWNER       = D.OWNER
AND    A.TABLE_NAME  = D.TABLE_NAME
AND    A.TABLE_NAME  LIKE UPPER('테이블명')
ORDER  BY A.OWNER, A.COLUMN_ID

참조

https://hermeslog.tistory.com/499

 


https://hermeslog.tistory.com/4

 

[Oracle] Table 목록 조회

1. 현재 계정의 테이블 목록을 보여줌. SELECT * FROM tab; SELECT * FROM ALL_TABLES WHERE TABLE_NAME LIKE '[TABLE명]' 2. 모든 계정의 테이블 목록을 보여줌. SELECT * FROM all_tables WHERE OWNER = SCOTT; SELECT * FROM user_tables; 3.

hermeslog.tistory.com

 

728x90