今天看了一哥们的博文,http://openlok.iteye.com/blog/2021580,突然想到以前每次测试的时候总是想知道那些表数据最多,今天从网上收集了下怎么得到表的行数及大小,本文SQL从网上收集的,本人测试通过。
首先是Mysql得到表行数,参考了链接:
http://stackoverflow.com/questions/433903/how-many-rows-in-mysql-database-table
SELECT table_schema, table_name, table_rows FROM information_schema.tables ORDER BY table_rows DESC
或者这样
SELECT table_schema, table_name, table_rows FROM information_schema.tables where table_schema='test' ORDER BY table_rows DESC
Mysql得到表大小,参考了链接:
http://stackoverflow.com/questions/9620198/how-to-get-the-sizes-of-the-tables-of-a-mysql-database
可以这样:
SELECT table_name AS "Tables", round(((data_length + index_length) / 1024 / 1024), 3) "MB" FROM information_schema.TABLES WHERE table_schema = "test" ORDER BY (data_length + index_length) DESC;
Mysql得到库的大小:
SELECT table_schema "DB Name", Round(Sum(data_length + index_length) / 1024 / 1024, 1) "DB Size in MB" FROM information_schema.tables GROUP BY table_schema order by sum(data_length + index_length) DESC;
上面的SQL在Mysql 5.6.14上面测试通过。
下面看Oracle怎么得到表的总行数及大小.
Oracle得到表的总行数,参考了链接:
http://www.dba-oracle.com/t_count_rows_all_tables_in_schema.htm
Sys用户可以这样:
select table_name, num_rows counter from dba_tables where owner = 'TMD' order by num_rows desc nulls last;
普通用户:
select table_name, num_rows counter from all_tables where owner = 'TMD' order by num_rows desc nulls last;
或者:
select table_name, num_rows counter from user_tables order by num_rows desc nulls last;
如果想得到一个文本汇总文件,可以写脚本,参考了链接:
http://www.dba-oracle.com/t_count_rows_all_tables_in_schema.htm
set pages 999; col count format 999,999,999; spool f:/saveFile/tmp/countlist.txt select table_name, to_number( extractvalue( xmltype( dbms_xmlgen.getxml('select count(*) c from '||table_name)) ,'/ROWSET/ROW/C')) count from user_tables order by table_name; spool off;
怎么得到表的大小呢?参考了链接:
https://community.oracle.com/thread/1113909
sys用户:
select segment_name,segment_type,bytes/1024/1024 MB from dba_segments where segment_type='TABLE' and OWNER = 'TMD' order by bytes desc;
普通用户,参考了链接:
http://www.dba-oracle.com/t_script_oracle_table_size.htm
select segment_name table_name, sum(bytes) / (1024 * 1024) table_size_meg from user_extents where segment_type = 'TABLE' group by segment_name;
上面的代码在oracle 10g测试通过。
本文中的SQL全部从网上收集,如有错误,欢迎指出,谢谢。
本文完。
相关推荐
ORACLE表生成MYSQL建表DDL
使用DBMover可以灵活定义Mysql和Oracle之间表和字段的对照关系,也可以在DBMover创建一个查询,把查询结果当作源表转入到Oracle中。 Dbmover for Mysql to Oracle 可以定时,定周期自动运行。 支持 Oracle 8i 以后...
Mysql的表对象Sql语句转换单表,转换成Oracle创建表sql,在样本.txt粘贴Mysql的单表所有字段信息,输入表名。就会在控件台输出转换后的Oracle语句。
mysql oracle 阿拉伯数字转中文数字, 亲测可用.找了很长时间才找到,
数据库 Mysql转oracle sql脚本转oracle脚本
Convert Mysql to Oracle 最新版本:4.0 Convert Mysql to Oracle是一个免费的数据库转换工具,实现快速安全地将Mysql数据库导入为ORACLE数据库。 Convert Mysql to Oracle 功能特点 可以转换所有的Mysql字段类型 ...
支持MYSQL和ORACLE!!!
oracle向mysql建表语句的迁移。 直接表结构的生成sql脚本
Oracle to MySQL Oracle 转 MySQL亲自测试,好用
mysql数据库转oracle工具,解压即用,支持表结构转换a
4. MySQL整体架构及工作原理 18 5. MySQL与ORACLE区别 19 6. 可视化工具 38 三、 ORACLE介绍 38 1. ORACLE是什么? 38 2. ORACLE核心特点是什么? 38 3. ORACLE数据库类型有哪些? 39 4. ORACLE整体架构及工作原理?...
支持Mysql与oracle自动在excel中生成创建sql语句,非常强大,如果想使用sqlserver看我上一资源
Mysql Oracle 数据库开发设计及使用规范
一个mysql数据库数据同步至oracle数据库代码,同时修改mysql数据表标识。
mysql和Oracle的多数据源配置,springboot+mysql+oracle
Flume二次开发,支持抽取MYSQL Oracle数据库数据 以JSON格式推送至Kafka。 demo: sql_json.sources.sql_source.type = com.hbn.rdb.source.SQLSource sql_json.sources.sql_source.connectionurl = jdbc:oracle:...
mysql oracle驱动jar包,对于开发系统连接mysql oracle可用,
MySQL、PostgreSQL、Oracle比较; 数据库基础知识.ppt
MySQL to Oracle MySQL 转 Oracle亲自测试,好用
使用PowerDesigner将Oracle数据中的库表转换为Mysql中的库表格式