ALTER TABLE - add several columns

From: Fuchs Clemens <clemens(dot)fuchs(at)siemens(dot)com>
To: "'pgsql-general(at)postgresql(dot)org'" <pgsql-general(at)postgresql(dot)org>
Subject: ALTER TABLE - add several columns
Date: 2004-08-26 06:30:15
Message-ID: 9DDD01E6B277D511B22300A0C9EEE776025D524E@LNZP106A
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

I just want to add several columns to an existing table. Do I have to call a
statements like below for each new column, or is there a possibility to do
it at once?

- existing table: test
- columns to add: col1 (FK), col2

ALTER TABLE test ADD col1 INT2 NULL;
ALTER TABLE test ADD CONSTRAINT col1_fk FOREIGN KEY (col1) REFERENCES
xy(col1);
ALTER TABLE test ADD col2 INT2 NULL;

I'd rather like to execute a statement like this:

ALTER TABLE test ADD (
col1 INT2 NULL,
col2 INT2 NULL,
FOREIGN KEY (col1) REFERENCES xy(col1)
);

thx,
Clemens

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Igor Kryltsov 2004-08-26 06:48:12 FK question
Previous Message Joe Conway 2004-08-26 05:51:05 Re: Substring RegExp Extract path