欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

导出数据库表结构到excel

程序员文章站 2024-03-21 08:19:40
...

SELECT '字段名称','数据类型','主键','备注'
UNION
SELECT
	COLUMN_NAME as 字段名称,
	COLUMN_TYPE as 数据类型,
	if(COLUMN_KEY='PRI','Y','N') as 主键,
	COLUMN_COMMENT as 备注
FROM
	INFORMATION_SCHEMA. COLUMNS
WHERE
	table_schema = '数据库名'
AND 
	table_name = '表名'
INTO OUTFILE 'D:/XXX.xls'