To get the total number of rows in a Mysql database, you can use aggregate function SUM() along with inbuilt column TABL
To get the total number of rows in a Mysql database, you can use aggregate function SUM() along with inbuilt column TABLE_ROWS from INFORMATION_SCHEMA.TABLES.
The syntax is as follows−
SELECT SUM(TABLE_ROWS)
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = database();
假设我们正在使用名为'sample'的数据库。
mysql> SELECT SUM(TABLE_ROWS)
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = database();
这将产生以下输出−
+-----------------+
| SUM(TABLE_ROWS) |
+-----------------+
| 2043 |
+-----------------+
1 row in set (22.11 sec)
--结束END--
本文标题: 我们可以获得 MySQL 数据库的总行数吗?
本文链接: https://www.lsjlt.com/news/438164.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-05-16
2024-05-16
2024-05-16
2024-05-15
2024-05-15
2024-05-15
2024-05-15
2024-05-15
2024-05-15
2024-05-15
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0