我有各种表格,每个表格都有超过一百个列,或者可以增加。此外,在我的表中,某些列的某些数据为空值,以及完全为空的列
我只需要具有完全空值的列或更好地理解该表的行数应该等于该表中存在的列的空数
DECLARE
TYPE refc IS ref CURSOR;
col_cv REFC;
l_query VARCHAR(3999);
v_rownum NUMBER;
v_count NUMBER;
BEGIN
l_query := 'select rownum from &table_name ';
FOR col IN (SELECT table_name,
column_name
FROM user_tab_columns
WHERE table_name = ' ') LOOP
l_query := l_query
||'DECODE('
||col.column_name
||',NULL,1,0)+';
END LOOP;
l_query := l_query
||'+0 as no_of_null_values from ... ';
dbms_output.Put_line(l_query);
OPEN col_cv FOR l_query;
LOOP
FETCH col_cv INTO v_rownum, v_count;
EXIT WHEN col_cv%NOTFOUND;
dbms_output.Put_line(v_rownum
|| ' '
|| v_count);
END LOOP;
CLOSE col_cv;
END;