Skip to Main Content
  • Questions
  • Finding records having columns which are blank in a table

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Satish.

Asked: December 09, 2020 - 3:46 pm UTC

Last updated: December 11, 2020 - 3:16 am UTC

Version: 11.2

Viewed 1000+ times

You Asked

I have a table with 100 columns. I need to retrieve records which have blank data in the columns without entering all the column names in query. Is it possible?

and Chris said...

No.

You'll have to list out all the columns that could be blank and check if they're null, e.g.:

where c1 is null or c2 is null or ...

Rating

  (1 rating)

Is this answer out of date? If it is, please let us know via a Comment

Comments

dynamic query

Sunny, December 10, 2020 - 4:37 am UTC

select s.COLUMN_NAME || case
when max(s.COLUMN_ID) over() != s.COLUMN_ID then
' is null or '
else
' is null '
end output

from user_tab_columns s
where s.TABLE_NAME = 'TABLE_NAME'
order by s.COLUMN_ID;

after write " select * from table_name where " and put above code output here
Connor McDonald
December 11, 2020 - 3:16 am UTC

SQL to generate SQL is of course a valid option to use

More to Explore

SQL

The Oracle documentation contains a complete SQL reference.