1. 程式人生 > >mysql 查詢所有資料庫中沒有主鍵的表

mysql 查詢所有資料庫中沒有主鍵的表

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' --排除系統庫
);