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();
登錄后復(fù)制
假設(shè)我們正在使用名為’sample’的數(shù)據(jù)庫。
現(xiàn)在我們將獲取MySQL數(shù)據(jù)庫中的總行數(shù)−
mysql> SELECT SUM(TABLE_ROWS) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = database();
登錄后復(fù)制
這將產(chǎn)生以下輸出−
+-----------------+ | SUM(TABLE_ROWS) | +-----------------+ | 2043 | +-----------------+ 1 row in set (22.11 sec)
登錄后復(fù)制
以上就是我們可以獲得 MySQL 數(shù)據(jù)庫的總行數(shù)嗎?的詳細(xì)內(nèi)容,更多請關(guān)注www.92cms.cn其它相關(guān)文章!