DECLARE CURSOR temp IS SELECT COLUMN_NAME FROM ALL_TAB_COLUMNS WHERE TABLE_NAME=Upper('xxx'); v_num NUMBER; BEGIN FOR i IN temp LOOP execute immediate 'SELECT Count(*) FROM xxx WHERE '||i.COLUMN_NAME||' IS NOT null' INTO v_num; IF v_num=0 THEN Dbms_Output.put_line('==columns that have no data=='||i.COLUMN_NAME); END IF; NULL; END LOOP; END;
xx为表名