How can I drop a “not null” constraint in Oracle when I don't know the name of the constraint?

前端 未结 7 1136
花落未央
花落未央 2020-12-07 20:10

I have a database which has a NOT NULL constraint on a field, and I want to remove this constraint. The complicating factor is that this constraint has a system-defined nam

7条回答
  •  独厮守ぢ
    2020-12-07 20:47

    I was facing the same problem trying to get around a custom check constraint that I needed to updated to allow different values. Problem is that ALL_CONSTRAINTS does't have a way to tell which column the constraint(s) are applied to. The way I managed to do it is by querying ALL_CONS_COLUMNS instead, then dropping each of the constraints by their name and recreate it.

    select constraint_name from all_cons_columns where table_name = [TABLE_NAME] and column_name = [COLUMN_NAME];

提交回复
热议问题