oracle和mysql查询所有表的注释和字段注释

mysql

SELECT
	t.table_name,
	t.table_comment,
	c.column_name,
	c.column_type,
	c.column_comment 
FROM
	information_schema.TABLES t
	LEFT JOIN information_schema.COLUMNS c ON c.table_name = t.table_name 
WHERE
	t.`table_schema` = 'world' 
-- 	查询所有表不需要这个,查询多张表罗列
	AND t.table_name = 'city' 
	OR t.table_name = 'country'

oracle

SELECT
	atc.TABLE_NAME "表名", --表名
	ace.COMMENTS "表注释", --表注释
	atc.COLUMN_NAME "列名", --列名
	atc.DATA_TYPE "字段类型", --字段类型
	atc.DATA_LENGTH "字段长度",--字段长度
	acc.COMMENTS "字段注释" --注释
FROM
	ALL_TAB_COLUMNS atc
	LEFT JOIN All_TAB_COMMENTS ace ON (atc.TABLE_NAME = ace.TABLE_NAME AND atc.OWNER = ace.OWNER )
	LEFT JOIN ALL_COL_COMMENTS acc ON (atc.TABLE_NAME = acc.TABLE_NAME AND atc.OWNER = acc.OWNER AND atc.COLUMN_NAME = acc.COLUMN_NAME)
WHERE
	1 = 1
	AND a

你可能感兴趣的:(基础,oracle,mysql,数据库)