mysql导出数据库表结构
1、导出sql
-- 数据库表结构
SELECT
col.TABLE_NAME 表名,
tab.TABLE_COMMENT 表中文名,
col.COLUMN_NAME 列名,
col.COLUMN_COMMENT 备注,
col.COLUMN_TYPE 数据类型,
col.DATA_TYPE 字段类型,
col.CHARACTER_MAXIMUM_LENGTH 长度,
col.IS_NULLABLE 是否为空,
col.COLUMN_DEFAULT 默认值
FROM
INFORMATION_SCHEMA.COLUMNS col
LEFT JOIN information_schema.TABLES tab on col.TABLE_NAME = tab.TABLE_NAME
WHERE
-- 对应的数据库
col.table_schema = 'db_hold_plan'
and col.table_name in ('product','product_grade','client_payment','interest_liquidation','interest_liquidation_his','sales_detail','commission_hold','redemption_rule','redemption','redemption_audit','redemption_lineitem')
and tab.TABLE_SCHEMA = 'db_hold_plan'
-- 排序
ORDER BY field(col.TABLE_NAME,'product','product_grade','client_payment','interest_liquidation','interest_liquidation_his','sales_detail','commission_hold','redemption_rule','redemption','redemption_audit','redemption_lineitem')