Oracle:查找仅具有空值的列 [英] Oracle: Finding Columns with only null values

查看:756
本文介绍了Oracle:查找仅具有空值的列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含很多列和一个type列的表.

I have a table with a lot of columns and a type column.

对于特定类型,某些列似乎总是空的.

Some columns seem to be always empty for a specific type.

我想为每种类型创建一个视图,并且只显示每种类型的相关列.在这样的假设下工作:如果一列只有特定类型的null值,那么该列不应该是视图的一部分,那么如何通过查询找到它?

I want to create a view for each type and only show the relevant columns for each type. Working under the assumption that if a column has ONLY null values for a specific type, then that columns should not be part of the view, how can you find that out with queries?

有没有 从[表]的[列值]中选择[列名]全部为[空]

Is there a SELECT [columnName] FROM [table] WHERE [columnValues] ARE ALL [null]

我知道我完全做到了……我只是想把这个想法传播出去. 预先感谢!

I know I COMPLETELY made it all up above... I'm just trying to get the idea across. Thanks in advance!

推荐答案

SELECT  t.column_name
FROM    user_tab_columns t
WHERE   t.nullable = 'Y'
        AND t.table_name = 'YOUR_TABLE_NAME'
        AND t.num_distinct = 0

这篇关于Oracle:查找仅具有空值的列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆