SELECT DBS.NAME AS OWNER,
TBLS.TBL_NAME as OBJECT_NAME,
TBL_COMMENTS.TBL_COMMENT as OBJECT_DESCRIPTION,
TBLS.TBL_ID as OBJECT_ID,
TBLS.TBL_TYPE as OBJECT_TYPE,
'VALID' as OBJECT_STATUS,
COLUMNS_V2.COLUMN_NAME,
COLUMNS_V2.COMMENT as COLUMN_DESCRIPTION,
COLUMNS_V2.TYPE_NAME AS DATA_TYPE,
'Y' as NULL_IND,
'N' as PRIMARY_KEY_IND,
TBLS.CREATE_TIME as LAST_DDL_TIME
FROM DBS
JOIN TBLS
ON DBS.DB_ID = TBLS.DB_ID
JOIN SDS
ON TBLS.SD_ID = SDS.SD_ID
JOIN COLUMNS_V2
ON COLUMNS_V2.CD_ID = SDS.CD_ID
JOIN (SELECT DISTINCT
TBL_ID,
TBL_COMMENT
FROM (SELECT TBLS.TBL_ID TBL_ID,
TABLE_PARAMS.PARAM_KEY,
TABLE_PARAMS.PARAM_VALUE,
CASE WHEN TABLE_PARAMS.PARAM_KEY = 'comment'
THEN TABLE_PARAMS.PARAM_VALUE
ELSE ''
END TBL_COMMENT
FROM TBLS
JOIN TABLE_PARAMS
ON TBLS.TBL_ID = TABLE_PARAMS.TBL_ID) TBL_COMMENTS_INTERNAL) TBL_COMMENTS
ON TBLS.TBL_ID = TBL_COMMENTS.TBL_ID;
1条答案
按热度按时间q3qa4bjr1#