在Navicat中新建查询,执行如下SQL语句即可:
SELECT
TABLE_SCHEMA as '数据库名称',
TABLE_NAME as '表名',
COLUMN_NAME as '字段名',
COLUMN_TYPE as '字段类型',
IS_NULLABLE as '是否空',
COLUMN_DEFAULT as '默认值',
(CASE COLUMN_KEY
WHEN 'PRI' THEN
'主键'
WHEN 'UNI' THEN
'唯一'
WHEN 'MUL' THEN
'非唯一'
ELSE
''
END) as '字段约束类型',
EXTRA as '字段自增',
COLUMN_COMMENT as '字段注释'
FROM
information_schema.COLUMNS
WHERE
TABLE_SCHEMA = '数据库名称';
查询结果如下:
使用Navicat导出查询结果功能按指导操作生成所需格式文件如下图所示:
!注意:导出结果时注意勾选“包含列的标题”。