Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8227627
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:11:13+00:00 2026-06-07T16:11:13+00:00

I have really big Oracle table with many columns that are not relevant to

  • 0

I have really big Oracle table with many columns that are not relevant to each filter that I use.

I want to write a query or function in Oracle that returns the name of the columns that have only null values or alternatively the name of the columns which are not null.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T16:11:16+00:00Added an answer on June 7, 2026 at 4:11 pm

    If you just want to find the columns that are always null you can run the query that this query creates, those columns that have a value 0 are null.

    select 'select ' 
           || listagg('count(' || column_name || ') as ' || column_name, ', ')
               within group (order by column_id)
           || ' from my_table;'
      from user_tab_columns
     where table_name = 'MY_TABLE'
    

    Here’s a SQL Fiddle to demonstrate.

    If you want the names of the columns you have to use PL/SQL. This function will return a comma delimited list of column names, but of course you could return a user defined type etc.

    create or replace function null_cols( P_TableName varchar2 ) return varchar2 is
    
       l_cols varchar2(32767);
       l_result number;
    
    begin
    
       for i in ( select column_name 
                    from user_tab_columns
                   where table_name = upper(P_TableName)
                         ) loop
    
          execute immediate 'select count(' || i.column_name || ')
                               from ' || P_TableName
                               into l_result;
    
          if l_result = 0 then
             l_cols := l_cols || i.column_name || ', ';
          end if;
    
       end loop;
    
       return l_cols;
    
    end;
    /
    

    Here’s an extension to the same SQL Fiddle with the function added.

    I have to just add that if you’re accepting user input in order to use the function you should use the dbms_assert package in order to help avoid SQL Injection.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a really big project that will use for example mails, contacts and
I have a quite complex, even though not really big, array, with many levels
I have a project that's not really big. With Visual Studio's C++ compiler the
I have a website that just takes a really big form and saves the
Lets say I have a really big table filled with lots of data (say,
i have a really big array of numbers with double precision...i tried to write
I have a really big number in Perl. I use "bignum". How can I
I have a really big .less file that I am trying to break into
I have an NodeJS Express app that is getting really big in just one
Ok, so say you have a really big Range in ruby. I want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.