pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dawid Kuroczko <qnex42@gmail.com>
To: Rafal Kedziorski <rafcio@polonium.de>
Cc: pgsql-admin@postgresql.org
Subject: Re: Add new column
Date: Wed, 20 Jul 2005 11:04:15 +0200
Message-ID: <758d5e7f050720020433f2f44d@mail.gmail.com> (raw)
In-Reply-To: <6.2.3.4.0.20050720104139.01e0e370@polonium.de>
References: <6.2.3.4.0.20050720104139.01e0e370@polonium.de>

On 7/20/05, Rafal Kedziorski <rafcio@polonium.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



view thread (4+ messages)  latest in thread

Message-ID: <758d5e7f050720020433f2f44d@mail.gmail.com>
Permalink:  ../758d5e7f050720020433f2f44d@mail.gmail.com/
Also on:    postgresql.org/message-id/758d5e7f050720020433f2f44d@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: qnex42@gmail.com, rafcio@polonium.de
  Subject: Re: Add new column
  In-Reply-To: <758d5e7f050720020433f2f44d@mail.gmail.com>
  References: <6.2.3.4.0.20050720104139.01e0e370@polonium.de> <758d5e7f050720020433f2f44d@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox