mysql批量设置自动允许null

2019-03-19 19:32 阅读 2,533 views 次 mysql批量设置自动允许null已关闭评论

将下面sql的结果拷贝到内存中再执行.  行里的字段显示不全,可点击右上角齿轮图标,设置一个字段字数为1000
select
CONCAT('ALTER TABLE `',TABLE_NAME,'` MODIFY COLUMN `',COLUMN_NAME,'` ',COLUMN_TYPE
,case when CHARACTER_SET_NAME is not null then CONCAT(' CHARACTER SET ',CHARACTER_SET_NAME,' COLLATE ',COLLATION_NAME) else '' end
,' NULL;') as alterSQL
from information_schema.`COLUMNS`
where TABLE_SCHEMA = 'mayidaohang' and TABLE_NAME like 'dueros_cmd_%'
and IS_NULLABLE = 'NO' and COLUMN_KEY not in ('PRI') and EXTRA not in ('auto_increment')
and COLUMN_DEFAULT is null

版权声明:本文著作权归原作者所有,欢迎分享本文,谢谢支持!
转载请注明:mysql批量设置自动允许null | 文档
分类:电脑技术 标签:

评论已关闭!