How to export database table structure information to Excel using Navicat Premium

Recently, when working on project acceptance documents, it is necessary to batch produce table structure information of database tables, write design documents, and display them in the form of two-dimensional tables in word documents. Therefore, the two-dimensional table style is formed with the help of Excel, which is convenient for display. After reading it, you can Use SQL script to export, the approximate steps are as follows:

1. Find out all the table names through the SQL statement.

select 

TABLE_COMMENT 表名,
TABLE_NAME 英文表名

from information_schema.tables  where TABLE_SCHEMA='你的数据库名称';

2. Query all field information of the table through the table name.

SELECT
COLUMN_NAME 标识符,
COLUMN_COMMENT 字段名,
COLUMN_TYPE 数据类型,
CHARACTER_MAXIMUM_LENGTH 长度,
NUMERIC_SCALE 小数位数,
COLUMN_KEY 是否是主键,
IS_NULLABLE 是否为空

FROM
INFORMATION_SCHEMA.COLUMNS
where
table_schema ='你的数据库名称' AND table_name = '你要导出的表名称' 
-- 表名,填写要导出的表的名称
-- 如果不写的话,默认查询所有表中的数据
-- 填写要导出表结构的数据库名称即可

3. Export to Excel file or directly copy to Excel file.

 

 

 


Guess you like

Origin blog.csdn.net/qq_35624642/article/details/127997174