根据表名 修改为小写
默认值会丢失
SELECT
CONCAT(
'alter table ',
TABLE_NAME,
' change column ',
COLUMN_NAME,
' ',
LOWER(COLUMN_NAME),
' ',
COLUMN_TYPE,
' comment "',
COLUMN_COMMENT,
'";'
) AS '修改脚本'
FROM
information_schema.COLUMNS
WHERE TABLE_SCHEMA = '数据库名' AND table_name = '表名';
默认值不会丢失
SELECT
CONCAT(
'alter table ',
TABLE_NAME,
' change column ',
COLUMN_NAME,
' ',
LOWER(COLUMN_NAME),
' ',
COLUMN_TYPE,
' default ',
COLUMN_DEFAULT,
' comment "',
COLUMN_COMMENT,
'";'
) AS '修改脚本'
FROM
information_schema.COLUMNS
WHERE TABLE_SCHEMA = '数据库名' AND table_name = '表名';
根据库名 修改为小写
SELECT
concat( 'alter table ', TABLE_NAME, ' change column ', COLUMN_NAME, ' ', LOWER( COLUMN_NAME ), ' ', COLUMN_TYPE, ' comment \'', COLUMN_COMMENT, '\';' ) AS '修改脚本'
FROM
information_schema.COLUMNS
WHERE
TABLE_SCHEMA = '数据库名'