数据库版本
oracle 11.2.0.4
postgresql11.6
mysql5.7.29
获取表名、表备注、表大小
oracle
select b.table_name,a.comments,b.BLOCKS from user_tab_comments a,user_tables b
where a.table_name=b.table_name
mysql
postgresql
select relname as tabname,pg_relation_size(relname::text),obj_description(relfilenode,‘pg_class’)::text as comment from pg_class c
where relname in (select tablename from pg_tables where schemaname=‘public’ and position(’_2’ in tablename)=0)
根据表名获取列名、列类型、是否为空
oracle
select c.COLUMN_NAME,c.DATA_TYPE,c.NULLABLE from user_tab_columns c where
postgresql
SELECT col_description(a.attrelid,
a.attnum) AS comment,
format_type(a.atttypid,
a.atttypmod) AS type,
a.attname AS name,
a.attnotnull AS notnull
FROM pg_class AS c,pg_attribute AS a
WHERE c.relname = ‘payment_types’
AND a.attrelid = c.oid
AND a.attnum>0
根据表名获取索引名以及索引组成字段
select c.index_name,c.column_name,c.COLUMN_POSITION from user_ind_columns c where table_name=‘GGPT_PMSR_GN_AUTHOR_USER’
order by c.COLUMN_POSITION asc