mysqlshow显示表的数量
下面的命令将让我知道数据库的名称 $mysqlshow 但是,我如何知道每个数据库中表的数量以及空表的数量呢? 例如 数据库计数为空 测试10 5 mydb 122 0 客户端34您可以使用mysqlshow显示表的数量,mysql,Mysql,下面的命令将让我知道数据库的名称 $mysqlshow 但是,我如何知道每个数据库中表的数量以及空表的数量呢? 例如 数据库计数为空 测试10 5 mydb 122 0 客户端34您可以使用 SHOW TABLES; 获取数据库中的表,然后计算返回的行数 您也可以这样做(尽管速度可能非常慢): 你可以用 SHOW TABLES; 获取数据库中的表,然后计算返回的行数 您也可以这样做(尽管速度可能非常慢): 如果您有权限,可以从information_schema.tables中选择count
SHOW TABLES;
获取数据库中的表,然后计算返回的行数
您也可以这样做(尽管速度可能非常慢):
你可以用
SHOW TABLES;
获取数据库中的表,然后计算返回的行数
您也可以这样做(尽管速度可能非常慢):
如果您有权限,可以从information_schema.tables中选择count(*)
select count(*) from information_schema.tables
where table_schema = <My Schema>
and table_type = 'BASE TABLE';
从information\u schema.tables中选择count(*)
其中,表_模式=
表_type='基表';
并在“表_行”列上筛选空yables:
select count(*) from information_schema.tables
where table_schema = <My Schema>
and table_type = 'BASE TABLE'
and table_rows = 0;
从information\u schema.tables中选择count(*)
其中,表_模式=
表类型='基表'
表_行=0;
如果您有权限,可以从information\u schema.tables中选择count(*)
select count(*) from information_schema.tables
where table_schema = <My Schema>
and table_type = 'BASE TABLE';
从information\u schema.tables中选择count(*)
其中,表_模式=
表_type='基表';
并在“表_行”列上筛选空yables:
select count(*) from information_schema.tables
where table_schema = <My Schema>
and table_type = 'BASE TABLE'
and table_rows = 0;
从information\u schema.tables中选择count(*)
其中,表_模式=
表类型='基表'
表_行=0;
有一个特殊的数据库,即信息模式,其中包含mysql服务器上所有数据库的元数据
SELECT `TABLE_NAME`, `TABLE_ROWS`
FROM `information_schema`.`TABLES`
WHERE `TABLE_SCHEMA` = 'NameOfDatabaseYouAreInterestedIn'
AND `TABLE_TYPE` = 'BASE TABLE'
表中的行并不总是完全准确的,您可能希望在表中循环并获得计数,因为有一个特殊的数据库,即包含mysql服务器上所有数据库元数据的信息模式
SELECT `TABLE_NAME`, `TABLE_ROWS`
FROM `information_schema`.`TABLES`
WHERE `TABLE_SCHEMA` = 'NameOfDatabaseYouAreInterestedIn'
AND `TABLE_TYPE` = 'BASE TABLE'
TABLE_ROWS并不总是完全准确的,您可能希望在表中循环并获取计数我不知道这是否有帮助,但有一个选项可以显示每个表的行数(
--count
):
如果传递数据库名称:
$mysqlshow --count tmp
Database: tmp
+------------+----------+------------+
| Tables | Columns | Total Rows |
+------------+----------+------------+
| builds | 2 | 0 |
| gtable | 2 | 5 |
| patterns | 9 | 0 |
| products | 2 | 0 |
| sig_types | 2 | 0 |
| signatures | 2 | 0 |
| versions | 2 | 0 |
+------------+----------+------------+
7 rows in set.
您可以添加tablename并获取有关它的信息:
$mysqlshow tmp gtable
Database: tmp Table: gtable
+--------+---------+-------------------+------+-----+---------+-------+---------------------------------+---------+
| Field | Type | Collation | Null | Key | Default | Extra | Privileges | Comment |
+--------+---------+-------------------+------+-----+---------+-------+---------------------------------+---------+
| symbol | text | latin1_swedish_ci | YES | | | | select,insert,update,references | |
| size | int(11) | | YES | | | | select,insert,update,references | |
+--------+---------+-------------------+------+-----+---------+-------+---------------------------------+---------+
查看
mysqlshow--help
了解更多选项/信息。我不知道这是否有帮助,但有一个mysqlshow
选项可以显示每个表的行数(--count
):
如果传递数据库名称:
$mysqlshow --count tmp
Database: tmp
+------------+----------+------------+
| Tables | Columns | Total Rows |
+------------+----------+------------+
| builds | 2 | 0 |
| gtable | 2 | 5 |
| patterns | 9 | 0 |
| products | 2 | 0 |
| sig_types | 2 | 0 |
| signatures | 2 | 0 |
| versions | 2 | 0 |
+------------+----------+------------+
7 rows in set.
您可以添加tablename并获取有关它的信息:
$mysqlshow tmp gtable
Database: tmp Table: gtable
+--------+---------+-------------------+------+-----+---------+-------+---------------------------------+---------+
| Field | Type | Collation | Null | Key | Default | Extra | Privileges | Comment |
+--------+---------+-------------------+------+-----+---------+-------+---------------------------------+---------+
| symbol | text | latin1_swedish_ci | YES | | | | select,insert,update,references | |
| size | int(11) | | YES | | | | select,insert,update,references | |
+--------+---------+-------------------+------+-----+---------+-------+---------------------------------+---------+
查看
mysqlshow--help
了解更多选项/信息。如果需要所有数据库的信息,可以从where子句中删除TABLE_架构如果需要所有数据库的信息,可以从where子句中删除TABLE_架构需要为这两条语句依次添加TABLE_TYPE
=“BASE TABLE”到where子句要从您的国家中删除视图,请感谢提供更多信息。将其添加到查询中,您需要为这两个语句的where子句添加TABLE\u TYPE
='BASE TABLE',以便从您的count中删除视图感谢提供的其他信息。将其添加到查询中,