MariaDB社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 6294|回复: 4
打印 上一主题 下一主题

计算数据库中所有表的记录数并输出.sql

[复制链接]
跳转到指定楼层
1#
发表于 2007-8-8 19:59:00 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
适用于MySQL5.0以上版本。

1、构造SQL语句

sql>use information_schema;

sql>select concat("select """, TABLE_name,""", count(*) from ", TABLE_name," union all") from tables where TABLE_SCHEMA='huashan';


2、执行后输出:
select "BackUpinfo", count(*) from BackUpinfo union all
select "CustomQuery", count(*) from CustomQuery union all
select "DATA_SOURCE", count(*) from DATA_SOURCE union all
select "DBTableList", count(*) from DBTableList union all
select "DBTableType", count(*) from DBTableType union all
select "DEVICE", count(*) from DEVICE union all

......


3、结果:

......
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 转播转播 分享分享 分享淘帖 顶 踩
5#
发表于 2009-11-27 10:13:38 | 只看该作者
nice
4#
发表于 2008-4-10 09:01:36 | 只看该作者
3#
 楼主| 发表于 2008-3-19 16:42:53 | 只看该作者
目前没有
2#
发表于 2008-3-19 11:28:15 | 只看该作者
赞!

mysql 4.1中无information_schema表。

mysql> use information_schema;
ERROR 1049 (42000): Unknown database 'information_schema'

还有其他办法吗?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|小黑屋|手机版|MariaDB社区 ( 京ICP备07012489号    |
业务联系: QQ:48474881; 邮箱: 48474881@qq.com; 电话:13911732319
声明:本站部分文章是网友转载,若未经作者同意或署名有误,请联系网站管理员。

GMT+8, 2024-9-20 05:27 , Processed in 0.078100 second(s), 23 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表