mysql查询没有主键的表


 

 

mysql> SELECT t.table_schema, t.table_name FROM information_schema.tables t LEFT JOIN information_schema.columns c ON t.table_schema = c.table_schema AND t.table_name = c.table_name WHERE
t.table_type = 'BASE TABLE' AND t.table_schema NOT IN ('mysql', 'sys', 'performance_schema', 'information_schema') GROUP BY t.table_schema, t.table_name HAVING sum(if(c.column_key='PRI', 1
, 0)) = 0;
+--------------+------------+
| table_schema | table_name |
+--------------+------------+
| emm_imserver | t1 |
| emm_imserver | t2 |
| emm_imserver | t3 |
| test | t |
+--------------+------------+
4 rows in set, 48 warnings (0.37 sec)

mysql>


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM