(Oracle)数据量统计存储过程
本过程适用于Oracle数据量统计。
create or replace procedure SP_GET_TAB_COUNT as v_tableName HDSD_TJ.Tablename%type; v_tableCount HDSD_TJ.Tablecount%type; v_tmp varchar2(500); v_tmp2 varchar2(500); v_tmp3 varchar2(500); cursor cur_tab is select tableName from HDSD_TJ; begin open cur_tab; loop fetch cur_tab into v_tableName; exit when cur_tab%notfound; v_tmp:='analyze table '||v_tableName||' estimate statistics'; execute immediate v_tmp; v_tmp2:= 'select num_rows from tabs where table_name ='''||v_tableName||''''; execute immediate v_tmp2 into v_tableCount; v_tmp3:='update HDSD_TJ set Tablecount='||v_tableCount||' where tableName ='''||v_tableName||''''; execute immediate v_tmp3; end loop; close cur_tab; end;
-- Create table create table HDSD_TJ ( tablename VARCHAR2(100), tablecount NUMBER(12) )