oracle:查找表子集的空列

umuewwlo  于 2021-08-13  发布在  Java
关注(0)|答案(1)|浏览(322)

在oracle数据库中,是否有方法返回表子集的所有空列?
类似

select
        t.column_name
from 
        user_tab_columns t
where   t.nullable = 'Y'
and     t.table_name = 'MY_TABLE'
and     t.num_nulls = (select count(*) from MY_TABLE);

除了我只想选择它的一个子集,而不是整个表my\ u table。
示例:如果我的表看起来像

A      B      C  
null | 1    | x  
null | null | y  
null | null | y

如果where子句是where c='y',我希望查询返回'a'和'b'。

0pizxfdo

0pizxfdo1#

如果你想要全部 null 可以使用外部联接的列:

select t.*
from (select 1 as n from dual) x left join
     my_table t
     on 1 = 0;

相关问题