SELECT
'COMMENT ON TABLE ' || A.TABLE_NAME || ' IS ''' ||
REGEXP_REPLACE(comments, '[\n\r\t]+', ' ') || ''';' AS sql
FROM
USER_TABLES A
LEFT JOIN
USER_TAB_COMMENTS B
ON
A.TABLE_NAME = B.TABLE_NAME
where comments is not null
union all
SELECT
'COMMENT ON COLUMN ' || A.TABLE_NAME || '.' || A.COLUMN_NAME ||
' IS ''' || REGEXP_REPLACE(comments, '[\n\r\t]+', ' ') || ''';' AS sql
FROM USER_TAB_COLUMNS A LEFT JOIN USER_COL_COMMENTS B
ON A.TABLE_NAME = B.TABLE_NAME AND A.COLUMN_NAME = B.COLUMN_NAME
where comments is not null
oracle查询表和字段所有注释
最新推荐文章于 2024-07-23 23:58:27 发布