SELECT C.TABLE_CATALOG
, C.TABLE_SCHEMA
, C.TABLE_NAME
, C.COLUMN_NAME
, C.DATA_TYPE
, C.CHARACTER_MAXIMUM_LENGTH AS CHAR
, C.CHARACTER_OCTET_LENGTH AS BYTE
, C.NUMERIC_PRECISION
, C.NUMERIC_SCALE
, CASE C.IS_NULLABLE
WHEN 'YES' THEN 'NULL'
WHEN 'NO' THEN 'NOT NULL'
END AS NULLABLE
, C.COLUMN_DEFAULT
, C.ORDINAL_POSITION
, K.PK
, K.FK
FROM INFORMATION_SCHEMA.COLUMNS C
LEFT OUTER JOIN (SELECT TABLE_CATALOG
, TABLE_SCHEMA
, TABLE_NAME
, COLUMN_NAME
, MAX(PK) AS PK
, MAX(FK) AS FK
FROM (SELECT P.TABLE_CATALOG
, P.TABLE_SCHEMA
, P.TABLE_NAME
, P.COLUMN_NAME
, CASE WHEN F.CONSTRAINT_NAME IS NULL
THEN P.CONSTRAINT_NAME
ELSE NULL
END AS PK
, F.CONSTRAINT_NAME AS FK
FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE P
LEFT OUTER JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS F ON F.CONSTRAINT_CATALOG = P.CONSTRAINT_CATALOG
AND F.CONSTRAINT_SCHEMA = P.CONSTRAINT_SCHEMA
AND F.CONSTRAINT_NAME = P.CONSTRAINT_NAME) K
GROUP BY TABLE_CATALOG
, TABLE_SCHEMA
, TABLE_NAME
, COLUMN_NAME) K ON K.TABLE_CATALOG = C.TABLE_CATALOG
AND K.TABLE_SCHEMA = C.TABLE_SCHEMA
AND K.TABLE_NAME = C.TABLE_NAME
AND K.COLUMN_NAME = C.COLUMN_NAME
ORDER BY C.TABLE_NAME ASC
, C.ORDINAL_POSITION ASC;
테이블, 컬럼 정보 조회
|
2012.07.02 15:26:42
|
2012.07.02 15:26:42
|
481
|
Aiden
Total of Attached file
0.00 Bytes of 0 files
2012.07.19
2012.07.18
2012.07.10
2012.07.05
2012.07.03
2012.07.02
2012.06.29
2012.06.25
2012.06.23
2012.06.22
2012.06.21