项目上报材料的SQL,将查询结果导出excel可以直接复制到导入模板后上报数据局。
SELECT
'业务系统名称' AS '业务系统名称'
,IF( length( t.TABLE_COMMENT )> 0, t.TABLE_COMMENT, c.table_name ) AS '库表中文名'
,c.table_name AS '库表名称'
,'MYSQL' AS '数据库类型'
,t.TABLE_ROWS AS '数据量(条)'
,IF( length( c.COLUMN_COMMENT )> 0, c.COLUMN_COMMENT, c.COLUMN_NAME ) AS '数据项中文名'
,c.COLUMN_NAME AS '数据项名称'
,c.DATA_TYPE AS '数据类型'
,IFNULL( c.CHARACTER_MAXIMUM_LENGTH, NUMERIC_PRECISION ) AS '数据长度'
,IF( c.COLUMN_KEY = 'PRI', '是', '否' ) AS '是否主键'
,IF( c.IS_NULLABLE = 'YES', '是', '否' ) AS '是否可为空'
,c.NUMERIC_SCALE AS '小数位'
,c.COLUMN_TYPE AS '数据类型'
FROM
information_schema.TABLES t
INNER JOIN information_schema.COLUMNS c ON t.TABLE_SCHEMA = c.TABLE_SCHEMA
AND t.TABLE_NAME = c.TABLE_NAME
WHERE
t.TABLE_TYPE = 'BASE TABLE'
AND t.TABLE_SCHEMA = 'your_database_name' -- 替换为你的数据库名称
ORDER BY
t.TABLE_NAME,
c.ORDINAL_POSITION;
|