From: | Nis Jørgensen <nis(at)superlativ(dot)dk> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: alter table table add column |
Date: | 2007-07-31 07:56:47 |
Message-ID: | f8mq0h$9pg$1@sea.gmane.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-admin pgsql-general pgsql-novice pgsql-sql |
Ronald Rojas skrev:
> Hi,
>
> Anybody knows how to add column with reference to BEFORE or AFTER any
> given column? Let say here's my table structure:
>
> Column | Type | Modifiers
> ----------+-------------------+-----------
> surname | character varying |
> lastname | character varying |
> address | character varying |
>
> And, I want to add the field name age with type integer after lastname
> OR before the address field. How to I do that?
>
> I would really appreciate your response.
Not tested.
ALTER TABLE foo ADD COLUMN age integer
ALTER TABLE foo ADD COLUMN address2 character varying;
UPDATE TABLE foo SET address2=address;
ALTER TABLE foo DROP COLUMN address;
ALTER TABLE foo RENAME COLUMN address2 TO address;
Nis
From | Date | Subject | |
---|---|---|---|
Next Message | Shane Ambler | 2007-07-31 09:19:30 | Re: deinstallation - reinstallation on Mac OS 10.4 |
Previous Message | Peter Childs | 2007-07-31 07:54:15 | Re: [NOVICE] alter table table add column |
From | Date | Subject | |
---|---|---|---|
Next Message | Victor Adolfsson | 2007-07-31 09:56:14 | Performance problem with large resultsets (byte array 2200) |
Previous Message | Peter Childs | 2007-07-31 07:54:15 | Re: [NOVICE] alter table table add column |
From | Date | Subject | |
---|---|---|---|
Next Message | Oliver Elphick | 2007-07-31 10:20:31 | Re: tsearch2.sql and different versions of PostgreSQL |
Previous Message | Peter Childs | 2007-07-31 07:54:15 | Re: [NOVICE] alter table table add column |
From | Date | Subject | |
---|---|---|---|
Next Message | Jyoti Seth | 2007-07-31 08:02:52 | Re: Database synchronization |
Previous Message | Peter Childs | 2007-07-31 07:54:15 | Re: [NOVICE] alter table table add column |