SELECT
a.table_name AS 表名,
b.comments AS 表备注,
(
SELECT
wmsys.wm_concat ( cu.COLUMN_NAME )
FROM
user_cons_columns cu,
user_constraints au
WHERE
cu.constraint_name = au.constraint_name
AND au.constraint_type = 'P'
AND au.table_name = a.table_name
) AS 主键
FROM
user_tables a,
user_tab_comments b
WHERE
a.table_name = b.table_name
ORDER BY
a.table_name
结果:多个主键会用逗号隔开,没有主键会显示空白