Adding "NOT NULL" Constraint with CREATE TABLE or ALTER TABLE - Mailing list pgsql-novice

From Phillip J. Allen
Subject Adding "NOT NULL" Constraint with CREATE TABLE or ALTER TABLE
Date
Msg-id 3DEF6577.8030101@attglobal.net
Whole thread Raw
Responses Re: Adding "NOT NULL" Constraint with CREATE TABLE or ALTER TABLE
List pgsql-novice
Hi all,

I have built my geology/mine database in Postgres and the front end in
MS Access(I hate it too but still haven't decided on a good
alternative).  Now when I ported my dbf to Postgres I didn't put all the
constraints and referencial integrety (relationships) into it so I am
now going back through it and refining it.

Now I am adding the "not null" constraints to various columns.  I am
adding them with the ALTER TABLE mytable ADD CONSTRAINT thekeyname_key
CHECK (thefield IS NOT NULL);.  When I do a \d+ thetable, psql returns
the proper constraint and all works fine.  But the constraint (not null)
does not appear in the modifiers colunm of the \d+ command but below the
column list as a Constraint.
Is adding the not null constraint at the time of creating a table the
same as adding a "constraint" later? If it is different is there a
performance difference?



Phillip J. Allen
Consulting Geochemist/Geologist


pgsql-novice by date:

Previous
From: David C.Oshel
Date:
Subject: Re: tcl script
Next
From: Joel Burton
Date:
Subject: Re: Adding "NOT NULL" Constraint with CREATE TABLE or ALTER TABLE