久久精品人人爽,华人av在线,亚洲性视频网站,欧美专区一二三

怎么在Oracle中對用戶中表的數據量進行統計

161次閱讀
沒有評論

共計 1800 個字符,預計需要花費 5 分鐘才能閱讀完成。

自動寫代碼機器人,免費開通

怎么在 Oracle 中對用戶中表的數據量進行統計?相信很多沒有經驗的人對此束手無策,為此本文總結了問題出現的原因和解決方法,通過這篇文章希望你能解決這個問題。

要想統計用戶下所有表的數據量,可以查看 user_tables,此表里面是統計信息,當然這個可能不太準,要想非常精確,需要直接 count 表。下面的腳本有異常不中斷,可以重復執行的特點。

create table bk_count_tables
 owner VARCHAR2(30),
 table_name VARCHAR2(30),
 part_col varchar2(100),-- 分區字段
 row_s number,
 gather_time date
create index ind_bct_own_table on bk_count_tables(owner,table_name);
set serveroutput on
declare
cursor c_cursor is select s.OWNER, s.TABLE_NAME, col.column_name part_col
 from dba_tables s,
 (select owner,
 name,
 listagg(column_name,  ,) within group(order by null) column_name
 from (select owner, name, column_name
 from dba_part_key_columns
 where owner in (TEST)
 and object_type =  TABLE 
 and name not like  BIN$% 
 union all
 select owner, name, column_name
 from dba_subpart_key_columns
 where owner in (TEST)
 and object_type =  TABLE 
 and name not like  BIN$% )
 group by owner, name) col
 where s.OWNER in (TEST)
 and not regexp_like(table_name,  [0-9]{3,8} )
 and s.table_name not like  %BAK% 
 and s.table_name not like  %A2K% 
 and s.table_name not like  BK% 
 and s.table_name not like  BIN% 
 and s.OWNER = col.owner(+)
 and s.TABLE_NAME = col.name(+)
order by s.TABLE_NAME ;
c_row c_cursor%rowtype;
t_rows number;
begin
 for c_row in c_cursor loop
 begin
 execute immediate  select count(*) from bk_count_tables where owner=:1 and TABLE_NAME=:2 and rownum=1  
 into t_rows using c_row.OWNER,c_row.TABLE_NAME ;
 if(t_rows = 0) then 
 execute immediate  select count(*) from  ||c_row.TABLE_NAME||  into t_rows;
 insert into bk_count_tables values(c_row.OWNER,c_row.TABLE_NAME,c_row.part_col,t_rows,sysdate);
 commit; 
 end if;
 EXCEPTION
 WHEN OTHERS THEN
 DBMS_OUTPUT.PUT_LINE(c_row.OWNER|| --- ||c_row.TABLE_NAME);
 rollback; 
 end;
 end loop;
/

看完上述內容,你們掌握怎么在 Oracle 中對用戶中表的數據量進行統計的方法了嗎?如果還想學到更多技能或想了解更多相關內容,歡迎關注丸趣 TV 行業資訊頻道,感謝各位的閱讀!

向 AI 問一下細節

正文完
 
丸趣
版權聲明:本站原創文章,由 丸趣 2023-12-16發表,共計1800字。
轉載說明:除特殊說明外本站除技術相關以外文章皆由網絡搜集發布,轉載請注明出處。
評論(沒有評論)
主站蜘蛛池模板: 肥西县| 监利县| 镇远县| 大渡口区| 庐江县| 佛冈县| 灵璧县| 大丰市| 崇阳县| 兴化市| 图木舒克市| 神农架林区| 桦川县| 和田市| 金坛市| 广安市| 河津市| 肇庆市| 西安市| 盐山县| 正镶白旗| 沾益县| 镇宁| 尚志市| 仙桃市| 襄樊市| 龙岩市| 长沙市| 新建县| 杭锦后旗| 卓资县| 肇州县| 宁国市| 武邑县| 平罗县| 麻栗坡县| 唐河县| 类乌齐县| 澄江县| 新绛县| 正阳县|