On Tue, 8 May 2001, John Pagakis wrote:
> I have a table - suppose it is called company:
> CREATE TABLE ( company_id char(36) NOT NULL UNIQUE PRIMARY KEY,
> I want to add the following field:
> company_nemonic char( 3 ) NOT NULL UNIQUE
> Well, ALTER TABLE only gets me part of the way there. While this code
> successfully adds the table:
> ALTER TABLE
> ADD COLUMN
> company_nemonic char( 3 ) NOT NULL UNIQUE;
> the constraints are ignored.
> Is there an easy way to add the constraints after the fact?
Unique is easy, you can create a unique index on the column which
is effectively what the unique constraint is doing behind the scenes.
Not null is harder, IIRC, you need to go and actually toggle
attnotnull in pg_attribute for the attribute.
In response to
pgsql-admin by date
|Next:||From: John Pagakis||Date: 2001-05-09 16:16:38|
|Subject: RE: Adding columns to existing tables|
|Previous:||From: Thomas Heller||Date: 2001-05-09 14:45:32|
|Subject: 7.1 ... wtf?|