From: | Dawid Kuroczko <qnex42(at)gmail(dot)com> |
---|---|
To: | Rafal Kedziorski <rafcio(at)polonium(dot)de> |
Cc: | pgsql-admin(at)postgresql(dot)org |
Subject: | Re: Add new column |
Date: | 2005-07-20 09:04:15 |
Message-ID: | 758d5e7f050720020433f2f44d@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-admin |
On 7/20/05, Rafal Kedziorski <rafcio(at)polonium(dot)de> wrote:
> Hi,
>
> I wan't add new column to this table:
>
> CREATE SEQUENCE abo_product_2_user_seq;
>
> CREATE TABLE abo_product_2_user (
> abo_product_2_user_id BIGINT NOT NULL DEFAULT
> NEXTVAL('abo_product_2_user_seq'),
> abo_product_id SMALLINT NOT NULL,
> user_id BIGINT NOT NULL,
> valid_from TIMESTAMP NOT NULL,
> valid_to TIMESTAMP,
> debit_entry VARCHAR(12) NOT NULL,
> --
> PRIMARY KEY (abo_product_2_user_id),
> --INDEX (abo_product_id),
> --INDEX (user_id),
> FOREIGN KEY (abo_product_id)
> REFERENCES abo_product (abo_product_id),
> FOREIGN KEY (user_id)
> REFERENCES users (user_id)
> );
>
> But PostgreSQL 8.0.3 adds the new column at the end. I want add this
> new column between user_id and valid_from.
Column reordering is not supported. If you really need an exact order
you have three choices:
1. Use explicit column names in SELECTs (not SELECT *).
2. CREATE VIEW with column order you desire.
3. Create a new table and populate it with data from old table, then drop
old table and rename the new one.
Regards,
Dawid
From | Date | Subject | |
---|---|---|---|
Next Message | Dawid Kuroczko | 2005-07-20 09:24:07 | Re: backing up without lock ? |
Previous Message | Rafal Kedziorski | 2005-07-20 08:49:20 | Add new column |