On Tue, Feb 11, 2003 at 16:55:28 +1300, Arunachalam Jaisankar <jsankar@xtra.co.nz> wrote:
> Hi all,
>
> I would like to have a foreign key column in my table which allows null value also.
> But the below create table sql command doesn't accept null value for person_id.
> How to do in postgres?
>
> create table event
> (
> event_id serial not null,
> event_description char(255) ,
> person_id serial ,
> primary key (event_id),
> foreign key (person_id)
> references person (person_id)
> );
I don't think you want to use serial type for a value that references
another table. Use integer instead. Serial also implies not null which
is why you couldn't stick null values into that field.