From: | Janning Vygen <vygen(at)gmx(dot)de> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Cc: | Fuchs Clemens <clemens(dot)fuchs(at)siemens(dot)com>, "'pgsql-general(at)postgresql(dot)org'" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: ALTER TABLE - add several columns |
Date: | 2004-08-26 07:53:03 |
Message-ID: | 200408260953.03631.vygen@gmx.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Am Donnerstag, 26. August 2004 08:30 schrieb Fuchs Clemens:
> 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)
> );
Take a look at http://www.postgresql.org/docs/7.4/static/sql-altertable.html
You can only add one column per statement, but of course you can place your
statements into a transaction.
kind regards
janning
From | Date | Subject | |
---|---|---|---|
Next Message | Martijn van Oosterhout | 2004-08-26 08:14:52 | Re: Querying large record sets |
Previous Message | Bjørn T Johansen | 2004-08-26 07:48:33 | Alter field type? |