时间:2021-07-01 10:21:17 帮助过:102人阅读
或者将表头赋值放在后面:
-- 数据字典 SELECT (CASE WHEN a.colorder = 1 THEN d.name ELSE ‘‘ END) 表名 ,a.colorder 字段序号 ,a.name 字段名 ,(CASE WHEN COLUMNPROPERTY(a.id, a.name, ‘IsIdentity‘) = 1 THEN ‘√‘ ELSE ‘‘ END) 标识 ,(CASE WHEN (SELECT COUNT(*) FROM sysobjects WHERE (name IN (SELECT name FROM sysindexes WHERE (id = a.id) AND (indid IN (SELECT indid FROM sysindexkeys WHERE (id = a.id) AND (colid IN (SELECT colid FROM syscolumns WHERE (id = a.id) AND (name = a.name)) )) )) ) AND (xtype = ‘PK‘)) > 0 THEN ‘√‘ ELSE ‘‘ END) 主键 ,b.name 类型 ,a.length 占用字节数 ,COLUMNPROPERTY(a.id, a.name, ‘PRECISION‘) AS 长度 ,ISNULL(COLUMNPROPERTY(a.id, a.name, ‘Scale‘), 0) AS 小数位数 ,(CASE WHEN a.isnullable = 1 THEN ‘√‘ ELSE ‘‘ END) 允许空 ,ISNULL(e.text, ‘‘) 默认值 ,ISNULL(g.[value], ‘‘) AS 字段说明 FROM syscolumns a LEFT JOIN systypes b ON a.xtype = b.xusertype INNER JOIN sysobjects d ON a.id = d.id AND d.xtype = ‘U‘ AND d.name <> ‘dtproperties‘ LEFT JOIN syscomments e ON a.cdefault = e.id LEFT JOIN sys.extended_properties g ON a.id = g.major_id AND a.colid = g.major_id ORDER BY a.id, a.colorder
接下来将数据字典导出:
首先,点击右上角的导出
然后,选择导出格式:
选择导出的地址和输入文件的名称
参考:https://www.idaima.com/article/3083
MySQL,生成数据字典
USE information_schema; SELECT T.TABLE_SCHEMA AS ‘数据库名称‘, T.TABLE_NAME AS ‘表名‘, T.TABLE_TYPE AS ‘表类型‘, T. ENGINE AS ‘数据库引擎‘, C.ORDINAL_POSITION AS ‘字段编号‘, C.COLUMN_NAME AS ‘字段名‘, C.COLUMN_TYPE AS ‘数据类型‘, C.IS_NULLABLE AS ‘允许为空‘, C.COLUMN_KEY AS ‘键类型‘, C.EXTRA AS ‘自增属性‘, C.CHARACTER_SET_NAME AS ‘编码名称‘, C.COLUMN_COMMENT AS ‘字段说明‘ FROM COLUMNS C INNER JOIN TABLES T ON C.TABLE_SCHEMA = T.TABLE_SCHEMA AND C.TABLE_NAME = T.TABLE_NAME WHERE T.TABLE_SCHEMA = ‘mysql‘ --指定要生成数据字典的数据库
参考:http://www.jianshu.com/p/f491d0d3c503
Navicat Premium快速导出数据库ER图和数据字典
标签:cat 编号 navicat mysq 字典 length inner sql mysql