Empty table identification in Oracle Database

Source: Internet
Author: User
In the Oracle database, find the empty table without DECLAREv_tabletabs.table_name % TYPE; v_sqlVARCHAR2 (888); v_qNUMBER; struct; TYPEcISREFCURSOR; C2C; partition (the table name of the empty data table is as follows:); FORr1INc1LOOP

In the Oracle database, find the empty table without 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 ('table name of the empty data table below: '); FOR r1 IN c1 LOOP

Empty table identification in Oracle Database <无>
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 ('table name of the empty data table below: '); FOR r1 IN c1 LOOP v_table: = r1.tn; v_ SQL: = 'select COUNT (*) q from' | v_table; 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;
SELECT * FROM dba_segments WHERE blocks <= 1 AND segment_type = 'TABLE';

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.