mysql导出表结构为Excel

SELECT
	a.table_name 表名,
	b.table_comment 表描述,
	a.COLUMN_NAME 列名,
	a.COLUMN_TYPE 数据类型,
	a.DATA_TYPE 字段类型,
	a.CHARACTER_MAXIMUM_LENGTH 长度,
	a.IS_NULLABLE 是否为空,
	a.COLUMN_DEFAULT 默认值,
	a.COLUMN_COMMENT 备注 
FROM
	(SELECT
		table_name,
		COLUMN_NAME,
		COLUMN_TYPE,
		DATA_TYPE,
		CHARACTER_MAXIMUM_LENGTH,
		IS_NULLABLE,
		COLUMN_DEFAULT,
		COLUMN_COMMENT 
	FROM
		INFORMATION_SCHEMA.COLUMNS 
		WHERE
		table_schema = '' 
	AND table_name IN ( SELECT table_name FROM information_schema.TABLES WHERE table_schema = '' )
	) a
JOIN 
	( SELECT table_name, table_comment FROM information_schema.TABLES WHERE table_schema = '' ) b 
ON a.table_name = b.table_name

你可能感兴趣的:(mysql,excel,数据库)