SQL检查数据库是否为空(无表) [英] SQL to check if database is empty (no tables)
本文介绍了SQL检查数据库是否为空(无表)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要使用SQL查询来检查数据库是否完全为空(无表).该怎么办?
I need to check if a database is totally empty (no tables) using an SQL query. How can this be done?
感谢您的帮助!
推荐答案
SELECT COUNT(DISTINCT `table_name`) FROM `information_schema`.`columns` WHERE `table_schema` = 'your_db_name'
将返回数据库中表(或视图)的实际数量.如果该数字为0,则没有表格.
will return the actual number of tables (or views) in your DB. If that number is 0, then there are no tables.
这篇关于SQL检查数据库是否为空(无表)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文