Select the number of rows in all tables in the database

I wonder if this is possible using direct SQL in MySQL. I need to do a SELECT COUNT (*) FROM on each table in the database and output the results in one result set.

Can I use only SQL?

+3
source share
2 answers

In fact. You must use INFORMATION_SCHEMA. INFORMATION_SCHEMA.tables has a TABLE_ROWS column.

http://dev.mysql.com/doc/refman/5.0/en/tables-table.html

+3
source

if one SQL is considered a stored process, then yes!

.. you can do with cursor and dynamic sql.

exec("select count(*) from " + @tableName) 

.... type of item!

I'm sure mysql probably has embedded SQL or SP that will do this for you, I'm afraid I don't know what it is.

0

Source: https://habr.com/ru/post/1749116/


All Articles