Re: Re: ALTER TABLE ADD CONSTRAINT

From: Jeff Daugherty <jdaugherty(at)greatbridge(dot)com>
To: Gregory Wood <gregw(at)com-stock(dot)com>
Cc: PostgreSQL-General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Re: ALTER TABLE ADD CONSTRAINT
Date: 2001-05-11 19:29:12
Message-ID: 3AFC3D88.9050007@greatbridge.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

>> Also, I see that alter table add constraint does not work for defaults.
>>
>> Is this something that is going to be added?
>
> That I do hope will be added since the only way to replicate the
> functionality is to drop, readd and repopulate a table.
>
> Greg

I am not sure specifically what you are looking for but you can add a
default value to a column in an ALTER TABLE statement:

ALTER TABLE two ALTER COLUMN col_b SET DEFAULT 1;

Beyond that you can use another ALTER statement to add a Foreign Key
constraint to the column:

ALTER TABLE two ADD CONSTRAINT two_fk foreign key(col_b) REFERENCES
tbl_one(col_a) match full;

The biggest thing that I have noticed is many things require you to use
separate ALTER statements in order for them to work.

I hope this helps.

jeff

Jeff Daugherty
Database Systems Engineer
Great Bridge, LLC

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Stephan Szabo 2001-05-11 19:37:31 Re: ALTER TABLE ADD CONSTRAINT
Previous Message Andrew Perrin 2001-05-11 19:12:45 Re: PL/Perl without shared libperl.a