MySQL查询数据库中所有没有主键的表

select table_schema,table_name 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'
);

原文:http://blog.itpub.net/29254281/viewspace-2146092/

猜你喜欢

转载自my.oschina.net/u/3023401/blog/1801755