一、创建一个表
create table A
(
TABLE_NAME VARCHAR2(200),
COUNT_NUM NUMBER
)
二、创建一个存储过程
create or replace procedure tj_data as
-- 当前存储过程用到的变量
v_tableName VARCHAR2(100);
v_sql varchar2(200);
v_count integer;
-- 获取当前数据库中的所有表
CURSOR TABLE_LOOP IS SELECT Table_name FROM User_tables;
begin
-- 打开游标
delete from A;
OPEN TABLE_LOOP;
LOOP
FETCH TABLE_LOOP INTO v_tableName;
EXIT WHEN TABLE_LOOP %NOTFOUND;
v_sql:= 'select count(1) from '||v_tableName;
execute immediate v_sql into v_count;
insert into a values (v_tableName,v_count);
END LOOP;
CLOSE TABLE_LOOP;
end;
三、查出表数据不同的信息
select * from (
select t.table_name,t.num_rows from dba_tab_statistics t where t.owner=' 表空间' and table_name !='A' and t.table_name in (
SELECT Table_name FROM User_tables)) B,A where a.table_name=b.table_name
(
TABLE_NAME VARCHAR2(200),
COUNT_NUM NUMBER
)
二、创建一个存储过程
create or replace procedure tj_data as
-- 当前存储过程用到的变量
v_tableName VARCHAR2(100);
v_sql varchar2(200);
v_count integer;
-- 获取当前数据库中的所有表
CURSOR TABLE_LOOP IS SELECT Table_name FROM User_tables;
begin
-- 打开游标
delete from A;
OPEN TABLE_LOOP;
LOOP
FETCH TABLE_LOOP INTO v_tableName;
EXIT WHEN TABLE_LOOP %NOTFOUND;
v_sql:= 'select count(1) from '||v_tableName;
execute immediate v_sql into v_count;
insert into a values (v_tableName,v_count);
END LOOP;
CLOSE TABLE_LOOP;
end;
三、查出表数据不同的信息
select * from (
select t.table_name,t.num_rows from dba_tab_statistics t where t.owner=' 表空间' and table_name !='A' and t.table_name in (
SELECT Table_name FROM User_tables)) B,A where a.table_name=b.table_name