SELECT SUBSTR(a.TABLE_NAME,0,2) AS "업무구분" , a.TABLE_NAME AS "테이블명" , b.COMMENTS AS "테이블한글명" , a.COLUMN_ID AS "컬럼순번" , a.COLUMN_NAME AS "컬럼명" , c.COMMENTS AS "컬럼한글명" , a.DATA_TYPE AS "타입" , CASE WHEN NVL(a.DATA_SCALE,0) = 0 THEN TO_CHAR(a.DATA_LENGTH) ELSE a.DATA_LENGTH||'('||a.DATA_SCALE||')' END AS "길이" , CASE WHEN d.COLUMN_NAME IS NOT NULL THEN TO_CHAR(d.KEY_SEQ) ELSE '' END AS "KEY" , CASE WHEN a.nullable = 'N' THEN 'Y' ELSE '' END AS "NOT NULL" , a.DATA_DEFAULT AS "초기값" FROM ALL_TAB_COLUMNS a INNER JOIN ALL_TAB_COMMENTS b ON a.OWNER = b.OWNER AND a.TABLE_NAME = b.TABLE_NAME LEFT OUTER JOIN ALL_COL_COMMENTS c ON a.OWNER = c.OWNER AND a.TABLE_NAME = c.TABLE_NAME AND a.COLUMN_NAME = c.COLUMN_NAME LEFT OUTER JOIN ( SELECT ia.OWNER , ia.TABLE_NAME , ib.COLUMN_NAME , ib.POSITION AS KEY_SEQ FROM ALL_CONSTRAINTS ia INNER JOIN ALL_CONS_COLUMNS ib ON ia.OWNER = ib.OWNER AND ia.TABLE_NAME = ib.TABLE_NAME AND ia.CONSTRAINT_NAME = ib.CONSTRAINT_NAME AND ia.CONSTRAINT_TYPE = 'P' ) d ON a.OWNER = d.OWNER AND a.TABLE_NAME = d.TABLE_NAME AND a.COLUMN_NAME = d.COLUMN_NAME WHERE a.OWNER = 'SEMA_ERP' /* bx-erp : ERP, semis : SEMA_OWN */ AND a.TABLE_NAME LIKE '%_HIST%' /*조회할 Table명*/ -- AND a.TABLE_NAME = 'AM_CARDCONFMDTALSRECPT' /*조회할 Table명*/ -- AND b.COMMENTS LIKE '%원천징수%' /*조회할 Table명*/ -- AND a.TABLE_NAME = 'AM_SLIP_WRT_M' -- AND a.COLUMN_NAME LIKE '%ACNUT_NM_DIV_CD%' -- AND c.COMMENTS LIKE '%통화%코드%' -- AND a.column_name NOT LIKE '%#_%'ESCAPE'#' -- ORDER BY a.TABLE_NAME -- , a.COLUMN_ID ORDER BY a.TABLE_NAME , a.COLUMN_ID -- , a.COLUMN_NAME ;