SELECt a.table_name 表名, b.table_COMMENT 表备注, a.COLUMN_NAME 列名, a.COLUMN_TYPE 数据类型, IF ( c.INDEX_NAME = 'PRIMARY', 'YES', NULL ) 主键, a.IS_NULLABLE 是否可为空, a.COLUMN_DEFAULT 默认值, a.COLUMN_COMMENT 备注, a.table_schema 数据库 FROM INFORMATION_SCHEMA.COLUMNS a LEFT JOIN information_schema.TABLES b ON a.TABLE_NAME = b.TABLE_NAME AND a.table_schema = b.table_schema LEFT JOIN information_schema.statistics c ON a.TABLE_NAME = c.TABLE_NAME AND a.table_schema = c.table_schema AND a.COLUMN_NAME = c.COLUMN_NAME WHERe a.table_schema = 'your table schema' -- 数据库名称, 如果需要导出所有库的表结构,可以去掉该条件 ORDER BY a.table_schema, a.table_name



