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數據庫中的總行數−
mysql> SELECT SUM(TABLE_ROWS) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = database();
登錄后復制
這將產生以下輸出−
+-----------------+ | SUM(TABLE_ROWS) | +-----------------+ | 2043 | +-----------------+ 1 row in set (22.11 sec)
登錄后復制
以上就是我們可以獲得 MySQL 數據庫的總行數嗎?的詳細內容,更多請關注www.92cms.cn其它相關文章!