oracle查询问题

一张表有60个字段,如何查出这60个字段全部不为空的记录个数,小弟没思路,麻烦大家指点一下,谢谢

字段少的时候:
[code="sql"]select count(*) from tb where a is null and b is null[/code]

字段多的时候,:
[code="sql"]
DECLARE
TYPE myref IS REF CURSOR;
cur myref;
sqlStr VARCHAR2(200);
tb_name VARCHAR2(20);
TYPE arrays IS TABLE OF VARCHAR2(20) INDEX BY BINARY_INTEGER;
column_array arrays;
null_num INTEGER;
BEGIN
tb_name := 'TB';
sqlStr := 'SELECT column_name FROM user_tab_columns WHERE table_name = ''' ||
tb_name || '''';
OPEN cur FOR sqlStr;
FETCH cur BULK COLLECT
INTO column_array;
CLOSE cur;

sqlStr := 'SELECT COUNT(*) FROM ' || tb_name || ' WHERE 1=1';
FOR i IN column_array.FIRST .. column_array.LAST LOOP
    sqlStr := sqlStr || ' AND ' || column_array(i) || ' IS NULL ';
END LOOP;

EXECUTE IMMEDIATE sqlStr
    INTO null_num;
-- 都为空的记录数
dbms_output.put_line(null_num);

END;
[/code]

[code="java"]
例子

查询表里所有的字段可以用
SHOW COLUMNS FROM table
但我想查询表里不能为空的字段,于是
SHOW COLUMNS FROM table WHERE Null='NO'
语句没有错,提示成功执行,但却没有数据显示出来,我的表里已经将一些字段设为not null了

利用系统表information_schema.columns来查吧:

select table_schema,table_name,column_name
from information_schema.columns
where table_name='t111' and is_nullable='NO'
[/code]

比较笨的方法:把60个字段一一查询出来,再全部group一下,最后在having中加条件,所有字段都不为空。
select sum(count(*))
from invoicingreport a
group by a.company_id, a.terminal_id, a.remark
having a.remark is not null
and a.company_id is not null
and a.terminal_id is not null

逆向思维
delete from table where A is null or is null or c is null or d is null;
然后再统计
select count(*) from table

逆向思维
delete from table where a is null or b is null or c is null or d is null;
然后再统计
select count(*) from table

[code="java"]逆向思维
delete from table where A is null or is null or c is null or d is null;
然后再统计
select count(*) from table
[/code]