博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Script: Computing Table Size
阅读量:6158 次
发布时间:2019-06-21

本文共 2217 字,大约阅读时间需要 7 分钟。

This script calculates the average row size for all tables in a schema. It generates a script (getAvgCol.sql) from USER_TABLES and then runs it. The following type of SELECT is generated for each table in USER_TABLES: SELECT round(avg(nvl(vsize(COL1),0)) + round(avg(nvl(vsize(COL2),0)) + ... + round(avg(nvl(vsize(COLn),0)) Where n=# of cols. on the table Tables with LONG and LOB columns will not report row size properly. Also tables with object types will throw the following error and will also not report row size properly: ORA-00932: inconsistent datatypes ============= Sample Output ============= ACCOUNTS 6 ACCTS 39 ACCT_ADDRS 38 BAD_DATA 116 BASE1 6 BONUS CEG1 11 CHESS_SAVE CHESS_SAVE_PLAYER CITIES 36 COMPANY_SUMMARY 60 CR_FILES 113

Script:

SET ECHO offREM NAME:   ROWSZ.SQLdrop table column_counts;create table column_counts        (        table_name,        column_count        )        as        (        select table_name, max(column_id)        from user_tab_columns        where data_type not like 'LONG%' AND table_name in        (select table_name from user_tables)        group by table_name        )        ;set pages 0set tab onset trim onset verify offset feedback offset termout offset head offset lines 100set recsep offset embedded onspool getavgcol.sqlprompt column TB format A30prompt set head off recsep offprompt set lines 80 feedback off pages 0prompt spool getavgcolREMcolumn select_line format A8column end_line format A1column from_stmt format A34 word_wrapcolumn col_nm format A100column col_val format A32column tnm1 noprintcolumn tnmprint format A37column column_id noprintbreak on tnm1 skip 2set null ''clear breaksselect UTC.table_name tnm1,        decode(column_id,1,'select ' || chr(39) || UTC.table_name || chr(39) ||                ' TB, ', '        ') ||        'round(avg(nvl(vsize('||column_name||'),0)),0)' ||        decode(column_id,column_count, ' row_size from ' || UTC.table_name             || ';'|| chr(10)||chr(10),                ' +') col_nmfrom user_tab_columns UTC, column_counts CCwhere UTC.data_type not like 'LONG%' AND UTC.table_name = CC.table_nameorder by UTC.table_name, UTC.column_id;prompt spool offprompt exitspool offdrop table column_counts;exit

转载地址:http://rmafa.baihongyu.com/

你可能感兴趣的文章
Revit API找到风管穿过的墙(当前文档和链接文档)
查看>>
Scroll Depth – 衡量页面滚动的 Google 分析插件
查看>>
Windows 8.1 应用再出发 - 视图状态的更新
查看>>
自己制作交叉编译工具链
查看>>
Qt Style Sheet实践(四):行文本编辑框QLineEdit及自动补全
查看>>
[物理学与PDEs]第3章习题1 只有一个非零分量的磁场
查看>>
onInterceptTouchEvent和onTouchEvent调用时序
查看>>
android防止内存溢出浅析
查看>>
4.3.3版本之引擎bug
查看>>
SQL Server表分区详解
查看>>
STM32启动过程--启动文件--分析
查看>>
垂死挣扎还是涅槃重生 -- Delphi XE5 公布会归来感想
查看>>
淘宝的几个架构图
查看>>
linux后台运行程序
查看>>
Python异步IO --- 轻松管理10k+并发连接
查看>>
Oracle中drop user和drop user cascade的区别
查看>>
登记申请汇总
查看>>
Android Jni调用浅述
查看>>
CodeCombat森林关卡Python代码
查看>>
(二)Spring Boot 起步入门(翻译自Spring Boot官方教程文档)1.5.9.RELEASE
查看>>