Adding "NOT NULL" Constraint with CREATE TABLE or ALTER TABLE

From: "Phillip J(dot) Allen" <paallen(at)attglobal(dot)net>
To: pgsql-novice(at)postgresql(dot)org
Subject: Adding "NOT NULL" Constraint with CREATE TABLE or ALTER TABLE
Date: 2002-12-05 14:40:55
Message-ID: 3DEF6577.8030101@attglobal.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message David C.Oshel 2002-12-05 14:41:12 Re: tcl script
Previous Message Michael Remijan 2002-12-05 13:57:10 support for replication