MySQL query database for all tables without primary key

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'
);

Original text: http://blog.itpub.net/29254281/viewspace-2146092/

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324922550&siteId=291194637