简体   繁体   English

数据库中所有表的列表,以及每个表中的行数?

[英]List of all tables in database, and number of rows in each one?

有谁知道我将使用哪种MySQL语句返回包含数据库中所有表的列表以及每个表中的行数的结果?

try this 尝试这个

SELECT Table_name,Table_rows FROM 
information_schema.tables
WHERE TABLE_SCHEMA = 'yourdatabase'

show tables - for list of tables 显示表格-用于表格列表

show table status - should give you the name, number of rows, and a list of extra info 显示表格状态-应该给您名称,行数和其他信息列表

mysqlshow DBName --count

Use PEAR DB shortcuts methods. 使用PEAR DB快捷方式。

$db=DB::Connect("mysql://root@localhost/testdb");
$tab=$db->getListOf("tables");
....
$db->tableinfo("table_name");
...
$r=$db->query("select * from table_name");
echo $r->numrows();
echo $r->numcols();

I'm learning MySQL and didn't know about the show table status command. 我正在学习MySQL,但对show table status命令一无所知。 Nice One! 好东西!

As I said, I'm just starting, but already my database has over 2 million rows. 就像我说的那样,我才刚刚开始,但是我的数据库已经有超过200万行。

Does the host computer have to find storage for all rows if you 主机是否必须为所有行查找存储空间?

select * from table_name

Wouldn't it be simpler to say 说起来简单吗

select count(*) from table_name

and get only one row in return? 只得到一行回报?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM