查询mysql中没有主键的表

转载来自wc城,感谢

 1.查询语句

select concat('alter table ',table_schema,'.',table_name,' add column pkid bigint not null auto_increment primary key;')  from information_schema.tables  where (table_schema,table_name) not in(     select distinct table_schema,table_name from information_schema.columns where COLUMN_KEY='PRI'     ) and table_schema not in (     'sys','mysql','information_schema','performance_schema' );

2.查询结果

猜你喜欢

转载自blog.csdn.net/qq_35440040/article/details/88185508