X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C5DE1529A3 for ; Wed, 20 Jul 2005 06:05:06 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 19364-03 for ; Wed, 20 Jul 2005 09:05:00 +0000 (GMT) Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.200]) by svr1.postgresql.org (Postfix) with ESMTP id 804E0529AF for ; Wed, 20 Jul 2005 06:04:58 -0300 (ADT) Received: by zproxy.gmail.com with SMTP id 8so1367321nzo for ; Wed, 20 Jul 2005 02:05:00 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=UKiNtE5ux8p7jgf2YJzRNGXsibulOqkqIem0pO8WjlJ2PSFLSR10GchMGeA83ARJDgHUO4xgtNKS+XWWKDJC1TRApRu+cxEUrY6Wf5aocK3LNgu+WlrHyZsBuXTnjYMVoouUng8fBdFbn/02aGKx5lzNZhZV+v2ETdNTwSYMqs8= Received: by 10.36.77.12 with SMTP id z12mr4377nza; Wed, 20 Jul 2005 02:04:17 -0700 (PDT) Received: by 10.36.22.20 with HTTP; Wed, 20 Jul 2005 02:04:15 -0700 (PDT) Message-ID: <758d5e7f050720020433f2f44d@mail.gmail.com> Date: Wed, 20 Jul 2005 11:04:15 +0200 From: Dawid Kuroczko Reply-To: Dawid Kuroczko To: Rafal Kedziorski Subject: Re: Add new column Cc: pgsql-admin@postgresql.org In-Reply-To: <6.2.3.4.0.20050720104139.01e0e370@polonium.de> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <6.2.3.4.0.20050720104139.01e0e370@polonium.de> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.711 tagged_above=0 required=5 tests=AWL, FROM_ENDS_IN_NUMS, RCVD_BY_IP, UPPERCASE_25_50 X-Spam-Level: X-Archive-Number: 200507/146 X-Sequence-Number: 18202 On 7/20/05, Rafal Kedziorski wrote: > Hi, >=20 > I wan't add new column to this table: >=20 > CREATE SEQUENCE abo_product_2_user_seq; >=20 > 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) > ); >=20 > 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