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. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to be able to pull the column names which allow a NULL value, I know that

show columns from TABLE

Will give show me the table properties and whether or not the column allows null values, but is there a way to just return ONLY the columnnames which allow null.

show columns from TABLE where Null = 'YES' doesn't work, but it explains what I need to accomplish.

And of course it's easy to just pull everything and sort it out later on, but if there IS a way to do what I'm asking, I'd like to learn it.

share|improve this question
up vote 5 down vote accepted

Yes you can do it by using the information_schema database..

use the Query

FROM information_schema.COLUMNS 
  AND TABLE_NAME='table Name' 
share|improve this answer
SELECT table_schema, table_name, column_name
FROM information_schema.columns

Run describe on information_schema.columns to refine the results to your liking

share|improve this answer
+1 as you answered before me.. – Abdul Manaf Jun 12 '12 at 5:14

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.