oracle
SELECT DISTINCT atc.table_name AS "表名" ,atcom.comments AS "表注释" ,atc.column_id AS "字段序号" ,atc.column_name AS "字段名" ,atc.data_type AS "字段类型" ,atc.data_scale AS "字段精度" ,atc.data_length AS "字段长度" ,acc.comments AS "字段注释" ,allt.num_rows as "表数据量" FROM all_tab_columns atc INNER join all_col_comments acc ON atc.table_name = acc.table_name AND atc.owner = acc.owner AND atc.column_name = acc.column_name INNER join all_tab_comments atcom ON atc.table_name = atcom.table_name AND atcom.owner = acc.owner AND atcom.table_type = 'TABLE' INNER join all_tables allt on atc.table_name = allt.table_name AND atc.owner = allt.owner WHERE atc.owner = '数据库名' ORDER BY atc.table_name, atc.column_id
mysql
SELECT TABLE_NAME 表名, ORDINAL_POSITION 序号, COLUMN_NAME 字段名称, COLUMN_COMMENT 注释, IF( IS_NULLABLE = 'NO', '是', '' ) AS '必填', -- IS_NULLABLE = 'NO' 时,为必填,必填返回“是”,非必填返回空 COLUMN_TYPE 数据类型, IF( column_key='PRI','是','' ) AS '主键唯一' -- column_key='PRI' 时,为主键唯一索引,是返回“是”,否返回空 -- COLUMN_DEFAULT 默认值, -- CHARACTER_MAXIMUM_LENGTH 字符串最大长度【以字符为单位】, -- CHARACTER_OCTET_LENGTH 字符串最大长度【以字节为单位】, -- CHARACTER_SET_NAME 字符串字符集名称, -- COLLATION_NAME 字符串归类名称, -- NUMERIC_PRECISION 数字精度, -- NUMERIC_SCALE 数字刻度, -- DATETIME_PRECISION 时间分数秒精度 FROM INFORMATION_SCHEMA.COLUMNS WHERE-- performance_schema 为数据库名称,到时候只需要修改成你要导出表结构的数据库即可 table_schema = 'performance_schema' -- AND -- events_errors_summary_by_account_by_error 为表名,到时候换成你要导出的表的名称 -- 如果不写的话,默认会查询出该数据库中所有表的表结构;这里如果指定表名,则可以导出单独一个表的表结构 -- table_name = 'events_errors_summary_by_thread_by_error' ORDER BY TABLE_NAME, ORDINAL_POSITION
原创文章,作者:306829225,如若转载,请注明出处:https://blog.ytso.com/267426.html