SELECT
CONCAT(
'alter table ', table_schema, '.', table_name, ' modify column ', column_name, ' ', column_type,
IF(is_nullable = 'YES', '', ' not null'),
IF(column_default IS NULL, '',
IF(
data_type IN ('char', 'varchar')
OR
data_type IN ('date', 'datetime', 'timestamp') AND column_default != 'CURRENT_TIMESTAMP',
CONCAT(' default ', column_default),
CONCAT(' default ', column_default)
)
),
IF(extra IS NULL OR extra = '', '', concat(' ', extra)), ' comment '''';'
) s
FROM information_schema.columns
WHERE table_schema = '数据库名';
MySQL批量删除字段注释
最新推荐文章于 2024-04-12 17:48:23 发布