日期:2014-05-16 浏览次数:20545 次
SQL> DECLARE v_table tabs.table_name%TYPE; v_sql VARCHAR2(888); v_q NUMBER; CURSOR c1 IS SELECT table_name tn FROM tabs; TYPE c IS REF CURSOR; c2 c; BEGIN DBMS_OUTPUT.PUT_LINE('以下为空数据表的表名:'); FOR r1 IN c1 LOOP v_table :=r1.tn; v_sql :='SELECT count(*) q FROM '||v_table||' where rownum = 1'; OPEN c2 FOR v_sql; LOOP FETCH c2 INTO v_q; EXIT WHEN c2%NOTFOUND; IF v_q=0 THEN DBMS_OUTPUT.PUT_LINE(v_table); END IF; END LOOP; CLOSE c2; END LOOP; EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT.PUT_LINE('Error occurred'); END; / PL/SQL 过程已成功完成。 SQL> set serveroutput on SQL> /
T_FILE_INFO_RAW T_DOSSIER_INFO_RAW T_FONDS_INFO_RAW
SQL> exec dbms_stats.gather_schema_stats(user); PL/SQL 过程已成功完成。
SQL> exec dbms_stats.gather_schema_stats(user); PL/SQL 过程已成功完成。 -------------------- ---------- T_FILE_INFO_RAW 0 T_DOSSIER_INFO_RAW 0 T_FONDS_INFO_RAW 0
SQL> select count(*) from T_FILE_INFO_RAW; COUNT(*) 0 SQL> select count(*) from T_DOSSIER_INFO_RAW; COUNT(*) 0 SQL> select count(*) from T_FONDS_INFO_RAW; COUNT(*) 0
SQL> insert into T_FONDS_INFO_RAW (FILE_SUM) values(1111); 已创建 1 行。 SQL> insert into T_FONDS_INFO_RAW select * from T_FONDS_INFO_RAW; 已创建 1 行。 SQL> / 已创建2行。 SQL> / 已创建4行。 SQL> commit;
SQL> exec dbms_stats.gather_schema_stats(user); PL/SQL 过程已成功完成。 SQL> select table_name,num_rows from user_tables; TABLE_NAME NUM_ROWS ------------------------------ ---------- T_FILE_INFO_RAW 0 T_DOSSIER_INFO_RAW 0 T_FONDS_INFO_RAW 8 SQL> select count(*) from T_FONDS_INFO_RAW; COUNT(*) 8