Removing a NOT NULL
constraint
If you gave the NOT NULL
constraint a name when you created it, you can simply drop it:
alter table Adventures drop constraint IdNotNull
If you forgot the name, you can retrieve it with isql’s `SHOW TABLE
command (i.c. SHOW TABLE ADVENTURES
);other clients may have their own provisions to let you find or browse constraint names.
If you didn’t name the constraint explicitly, Firebird has created a name for it, but SHOW TABLE
won’t display it.You have to use this piece of SQL to dig it up:
select rc.rdb$constraint_name
from rdb$relation_constraints rc
join rdb$check_constraints cc
on rc.rdb$constraint_name = cc.rdb$constraint_name
where rc.rdb$constraint_type = 'NOT NULL'
and rc.rdb$relation_name = '<TableName>'
and cc.rdb$trigger_name = '<FieldName>'
Don’t break your head over some of the table and field names in this statement;they are illogical but correct.Make sure to uppercase the names of your table and field if they were defined case-insensitively.Otherwise, match the case exactly but don’t enclose the names in double-quotes like you would do in a regular query.Also don’t include the angle brackets (<>
). Once you have the constraint name, you can drop it just like in the previous example.
Tip
|
If the above statement returns an empty set and you are sure that you’ve correctly filled in the table and field names (including case!), and the constraint did not come from a domain either (this is discussed in the next sections), it may be that a third-party tool has made the column
If the flag is
followed by a commit. |
Important
|
As soon as you’ve dropped the However, before you can insert |