Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

Sorry about my earlier answer, I tried to do it too quickly (which is why I deleted). Hopefully I can get some time today to answer you. If someone else doesn't beat me first :)
–
Derek DowneyNov 15 '12 at 15:56

@DTest I would be very grateful if you figure out how to do it!
–
BazNov 15 '12 at 16:03

If you get two lists, no need to inspect the actual table because the table has non-NULL columns by definition.

If you get one list, then

If you get only is_nullable='NO', no need to inspect the actual table because the table has non-NULL columns by definition.

If you get only is_nullable='YES', the actual table would be a little brittle. There would be no PRIMARY KEY, you poor, tormented soul !!! NOW, you have to resort to reading every row from the actual table.

If you are looking for just the non-null columns, then this would be your desired query:

OK it works now. There is a problem still present. The query requires reading the entire table. My test table only has 117 rows and 20 columns. What about bigger tables with millions of rows or dozens of columns? I am not going to speculate because I know that the code would be orders of magnitude worse.