Subject Re: [firebird-support] primary key not null?
Author Ann W. Harrison
Dimitry Sibiryakov wrote:
>> .... But my question is: It's normal that FB didn't complain about having
>> a PK on a nullable column?
>
> I've just tested and it seems that FB silently added not null flag to
> field declared as primary key.
> If you create table with nullable column and then try to alter it
> adding primary key, FB will complain.
>

The SQL standard does not required that fields used as a primary
key be declared as NOT NULL. The PRIMARY KEY constraint imposes
NOT NULL implicitly. Other databases may require an explicit
NOT NULL - that' legal - but it's not required by the standard.

Good luck,

Ann

Just to be clear, NULLS are not allowed in a primary key, it's
just the stated NOT NULL constraint that's optional.