how to check for not null column constraint in oracle sql?

16,611
SELECT nullable
  FROM all_tab_cols
 WHERE owner = <<owner of table>>
   AND table_name = <<name of table>>
   AND column_name = <<name of column>>

will work assuming the column is marked NOT NULL rather than, say, having a CHECK constraint that checks that it is non-NULL.

Share:
16,611
serpiente
Author by

serpiente

Updated on July 12, 2022

Comments

  • serpiente
    serpiente almost 2 years

    How do i check if a column in a table has a not null constraint in an oracle db? Can it be checked with the data dictionary?

  • APC
    APC about 12 years
    People who use check constraints rather than column DDL to define not null columo.ns should be severely spoken to.
  • Dan Lenski
    Dan Lenski over 7 years
    @APC, agreed, but internally Oracle represents those NOT NULL columns with check constraints. They're utterly indistinguishable from ALL_CONSTRAINTS. RRgghgh. >:-(