I have a table with 260 columns, I just want to see only columns with nulls in it. I know there are a few longer versions to see that information but is there an quicker way ? Thanks Gurus

有帮助吗?

解决方案

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

Also,before running it update your statistics:

BEGIN
DBMS_STATS.gather_database_stats();
END

其他提示

If your question is about displaying Nullable table columns, look @Mihai...

You can definitely write dynamic Pl/Sql to build and execute a statement containing only columns that contain null. You can use series of loops, Ref_cursor, Execute Immediate, oracle data dictionaries, etc.

But if you would be able to, you would know already.

Regularly, you can select some data where certain values are null. E.g.

 Select * From myTable where Col1 is null or col2 is null... -- 258 more columns

This will return all 260 columns, N rows where at least one column is Null

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top