Welcome 微信登录

首页 / 数据库 / MySQL / Oracle表记录字节长长度的两种计算方式

一、获取某个用户下Oracle某个表行记录的长度这个长度是表字段定义的长度,获取方法:
  1. select owner,  
  2.        table_name,  
  3.        column_name,  
  4.        data_type,  
  5.        data_length,  
  6.        sumcase data_type  
  7.              when "DATE" then 
  8.               7  
  9.              when "NUMBER" then 
  10.               22  
  11.              else 
  12.               data_length  
  13.            end) length  
  14.   from all_tab_cols  
  15.  where table_name = upper"表名")  
  16.    and DATA_TYPE  
  17.    and owner=upper"用户名")  
  18.  group by rollup((owner, table_name, column_name, data_type, data_length)) 
二、根据表数据所占总字节数和表记录数来获取实际的每行记录的平均长度获取表数据的所有字节数:
  1. select segment_name,  
  2.        segment_type,  
  3.        nvl(sum(bytes), 0)   
  4.   from user_segments   
  5.  where segment_type = "TABLE"   
  6.    and segment_name = "表名"   
  7.  group by segment_name, segment_type   
  8.  order by 3 desc
获取表总记录数:select count(*) from 表名 两者求商即得每行记录的平均字节数。Ubuntu 下 MySQL 数据自执行备份Oracle:SQL Loader的导入文本数据相关资讯      oracle 
  • [INS-32052] Oracle基目录和Oracle  (07/22/2014 07:41:41)
  • Oracle 4个大对象(lobs)数据类型  (02/03/2013 12:33:05)
  • Oracle按时间段分组统计  (07/26/2012 10:36:48)
  • [Oracle] dbms_metadata.get_ddl的  (07/12/2013 07:37:30)
  • Liferay Portal 配置使用Oracle和  (07/31/2012 20:07:18)
  • Concurrent Request:Inactive   (07/20/2012 07:44:05)
本文评论 查看全部评论 (0)
表情: 姓名: 字数