查看mysql实例中哪些表字段可以为NULL/不可以为NULL

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Leon_liuqinburen/article/details/79126577
查看实例中哪些表字段可以为NULL
select t1.table_schema,t1.table_name,t2.COLUMN_NAME from information_schema.tables t1, information_schema.columns t2   
where t1.table_schema = t2.TABLE_SCHEMA  and t1.table_name = t2.TABLE_NAME  and t2.IS_NULLABLE in( 'YES') 
and t1.TABLE_SCHEMA not in ('information_schema','performance_schema','test','mysql', 'sys');


查看实例中哪些表字段不可以为NULL
select t1.table_schema,t1.table_name,t2.COLUMN_NAME from information_schema.tables t1, information_schema.columns t2   
where t1.table_schema = t2.TABLE_SCHEMA  and t1.table_name = t2.TABLE_NAME  and t2.IS_NULLABLE in( 'NO') 
and t1.TABLE_SCHEMA not in ('information_schema','performance_schema','test','mysql', 'sys');


猜你喜欢

转载自blog.csdn.net/Leon_liuqinburen/article/details/79126577