mysql 查找沒有主鍵(primary key)的表

select table_schema, table_name
  from information_schema.tables
 where 1=1
   and table_name not in (
        select distinct table_name
          from information_schema.columns
         where 1=1
		   and column_key = "PRI")
   and table_schema not in (
        'mysql', 
		'information_schema', 
		'sys', 
		'performance_schema'
	   );

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章