From ronald.rojas@gmail.com Tue Jul 31 04:20:19 2007 Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 895699FB52E for ; Tue, 31 Jul 2007 01:20:19 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 27053-10 for ; Tue, 31 Jul 2007 01:20:01 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from qb-out-0506.google.com (qb-out-0506.google.com [72.14.204.234]) by postgresql.org (Postfix) with ESMTP id 6EA149FB4C0 for ; Tue, 31 Jul 2007 01:20:01 -0300 (ADT) Received: by qb-out-0506.google.com with SMTP id o12so10615694qba for ; Mon, 30 Jul 2007 21:20:00 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:subject:from:to:content-type:date:message-id:mime-version:x-mailer; b=THV+Or9swsi22WNPKCIFWr67/3a1f6mQuQWMab7RbTQWS4ihfyxBw2q5Hj41PoB4b99/X+Va/XJzFuWLzZltjyYLGrrbWS8RykyotaXysTvr3DeWoNfPWlrlHdVmxyeQ9ucjS7cdfkWUecHnG+/ey/8ttwQ2p2BzzQGDe/9mw5Y= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:subject:from:to:content-type:date:message-id:mime-version:x-mailer; b=EjNCh7U/Y5Qzw50Y03DrR2yKHKPg42JyInn2I5/8dFmk3ONFtFZ3qq1x0yl0DdALjRSIuKjmMgiKvVG0vWT7IXyVX7pcX6V1StO9gY3n8BOVauSi7TyTm+Lb6C6lwRGMcholg1PjjhqTkOQPHhdWz8WJAQ+tW6ntL06HVIQjoU8= Received: by 10.141.177.2 with SMTP id e2mr2074700rvp.1185855600154; Mon, 30 Jul 2007 21:20:00 -0700 (PDT) Received: from ?133.88.3.33? ( [203.87.136.43]) by mx.google.com with ESMTPS id g31sm6213853rvb.2007.07.30.21.19.56 (version=SSLv3 cipher=RC4-MD5); Mon, 30 Jul 2007 21:19:59 -0700 (PDT) Subject: alter table table add column From: Ronald Rojas To: pgsql-sql@postgresql.org, pgsql-general@postgresql.org, pgsql-novice@postgresql.org, pgsql-admin@postgresql.org Content-Type: multipart/alternative; boundary="=-htvM2mI+vhFTy9WJ1d9K" Date: Tue, 31 Jul 2007 12:19:47 +0800 Message-Id: <1185855587.28634.6.camel@localhost> Mime-Version: 1.0 X-Mailer: Evolution 2.10.1 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200707/346 X-Sequence-Number: 26327 --=-htvM2mI+vhFTy9WJ1d9K Content-Type: text/plain Content-Transfer-Encoding: 7bit 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. Thanks in advance. ================================================================================================== Ronald Rojas Systems Administrator Linux Registered User #427229 ================================================================================================== Arnold's Laws of Documentation: (1) If it should exist, it doesn't. (2) If it does exist, it's out of date. (3) Only documentation for useless programs transcends the first two laws. --=-htvM2mI+vhFTy9WJ1d9K Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 7bit 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.

Thanks in advance.


==================================================================================================
Ronald Rojas
Systems Administrator
Linux Registered  User #427229
==================================================================================================

Arnold's Laws of Documentation:
	(1) If it should exist, it doesn't.
	(2) If it does exist, it's out of date.
	(3) Only documentation for useless programs transcends the
	    first two laws.


--=-htvM2mI+vhFTy9WJ1d9K-- From grzm@seespotcode.net Tue Jul 31 04:33:14 2007 Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 990389FB858; Tue, 31 Jul 2007 01:33:14 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 32747-05; Tue, 31 Jul 2007 01:33:01 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from mtao03.charter.net (mtao03.charter.net [209.225.8.188]) by postgresql.org (Postfix) with ESMTP id 626749FB72F; Tue, 31 Jul 2007 01:33:00 -0300 (ADT) Received: from aa04.charter.net ([10.20.200.156]) by mtao03.charter.net (InterMail vM.7.08.02.02 201-2186-121-104-20070414) with ESMTP id <20070731043259.BRIP24378.mtao03.charter.net@aa04.charter.net>; Tue, 31 Jul 2007 00:32:59 -0400 Received: from [10.0.1.3] (really [66.188.165.91]) by aa04.charter.net with ESMTP id <20070731043259.QOOW1254.aa04.charter.net@[10.0.1.3]>; Tue, 31 Jul 2007 00:32:59 -0400 In-Reply-To: <1185855587.28634.6.camel@localhost> References: <1185855587.28634.6.camel@localhost> Mime-Version: 1.0 (Apple Message framework v752.2) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <7F69A56D-27E8-43EE-BD1C-AB52C042B533@seespotcode.net> Cc: pgsql-sql@postgresql.org, pgsql-general@postgresql.org, pgsql-novice@postgresql.org, pgsql-admin@postgresql.org Content-Transfer-Encoding: 7bit From: Michael Glaesemann Subject: Re: [NOVICE] alter table table add column Date: Mon, 30 Jul 2007 23:32:53 -0500 To: Ronald Rojas X-Mailer: Apple Mail (2.752.2) X-Chzlrs: 0 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200707/347 X-Sequence-Number: 26328 [Please don't post the same question to many lists. Choose one. If you're unsure if it's the correct list for your question, ask if there's a more appropriate one. This question is find for -novice or - general. Thanks.] On Jul 30, 2007, at 23:19 , Ronald Rojas wrote: > And, I want to add the field name age with type integer after > lastname OR before the address field. How to I do that? Can't without dumping the database, altering the schema in the dump, and reloading. But why does it matter? Just call the columns in the order you want. Michael Glaesemann grzm seespotcode net From ronald.rojas@gmail.com Tue Jul 31 05:23:26 2007 Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 8542E9FBAF1 for ; Tue, 31 Jul 2007 02:23:26 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 49119-01-3 for ; Tue, 31 Jul 2007 02:23:22 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from rv-out-0910.google.com (rv-out-0910.google.com [209.85.198.185]) by postgresql.org (Postfix) with ESMTP id 8C37B9FBADE for ; Tue, 31 Jul 2007 02:23:22 -0300 (ADT) Received: by rv-out-0910.google.com with SMTP id f1so432481rvb for ; Mon, 30 Jul 2007 22:23:21 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:subject:from:to:cc:in-reply-to:references:content-type:date:message-id:mime-version:x-mailer; b=YGVJ9bk+Grp/r2ZciruNya8uqseQRdus19lW+0nh0s3oyjB4dVy9URfbwipeu+gc5CCTtTnbmN0wR5Qr8bCg2GYd1638skUGpkHiYZFhysY0DJp+DR0TiQVJxxsZItYUjQ2+K9yqi2+lSoUr9K2JzXgWxmwST3+O6FEQj8z8Dxg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:subject:from:to:cc:in-reply-to:references:content-type:date:message-id:mime-version:x-mailer; b=rT+906gUpbgXe2Cf5tInTJFgiDaoTeTRrwweMGxM5+oexNfN3voivbRU1tOYeyiluMnoXQnR1xctNWt4bbFh4iBFG9mvr/2AO2L7ttJ4NwWLXM7ahbfA5rP6NbKQrAlsKFEDaj/w4uBqNIJzq2F9ZG8CDSjlajkz7bmv/Jf4FwE= Received: by 10.141.41.12 with SMTP id t12mr2087631rvj.1185859401416; Mon, 30 Jul 2007 22:23:21 -0700 (PDT) Received: from ?133.88.3.33? ( [203.87.136.43]) by mx.google.com with ESMTPS id b34sm6288826rvf.2007.07.30.22.23.17 (version=SSLv3 cipher=RC4-MD5); Mon, 30 Jul 2007 22:23:20 -0700 (PDT) Subject: Re: [NOVICE] alter table table add column From: Ronald Rojas To: Michael Glaesemann Cc: pgsql-general@postgresql.org In-Reply-To: <7F69A56D-27E8-43EE-BD1C-AB52C042B533@seespotcode.net> References: <1185855587.28634.6.camel@localhost> <7F69A56D-27E8-43EE-BD1C-AB52C042B533@seespotcode.net> Content-Type: multipart/alternative; boundary="=-nP/62sg7AJCq8OiehIo6" Date: Tue, 31 Jul 2007 13:23:11 +0800 Message-Id: <1185859391.28634.17.camel@localhost> Mime-Version: 1.0 X-Mailer: Evolution 2.10.1 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200707/1190 X-Sequence-Number: 117791 --=-nP/62sg7AJCq8OiehIo6 Content-Type: text/plain Content-Transfer-Encoding: 7bit Hi, Sorry for doing the multiple mailing list recipient. Yes I know that procedure but I would like to insert in between because I have at third party software that will call the said schema and one of its dependencies with the mapping is it should have the correct order with what the receiving end will be use for the mapping. And in this case, I can't modify the receiving structure (third-party) and the tables that I will be using is in on production state. So would only mean that I have to schedule a very fast maintenance, probably 5 to 10 secs just to re-initialize the tables. Anyway, thanks for your input, really appreciate it. On Mon, 2007-07-30 at 23:32 -0500, Michael Glaesemann wrote: > [Please don't post the same question to many lists. Choose one. If > you're unsure if it's the correct list for your question, ask if > there's a more appropriate one. This question is find for -novice or - > general. Thanks.] > > On Jul 30, 2007, at 23:19 , Ronald Rojas wrote: > > > And, I want to add the field name age with type integer after > > lastname OR before the address field. How to I do that? > > Can't without dumping the database, altering the schema in the dump, > and reloading. But why does it matter? Just call the columns in the > order you want. > > Michael Glaesemann > grzm seespotcode net > > > ================================================================================================== Ronald Rojas Systems Administrator Linux Registered User #427229 ================================================================================================== Arnold's Laws of Documentation: (1) If it should exist, it doesn't. (2) If it does exist, it's out of date. (3) Only documentation for useless programs transcends the first two laws. --=-nP/62sg7AJCq8OiehIo6 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 7bit Hi,

Sorry for doing the multiple mailing list recipient. Yes I know that procedure but I would like to insert in between because I have at third party software that will call the said schema and one of its dependencies with the mapping is it should have the correct order with what the receiving end will be use for the mapping. And in this case, I can't modify the receiving structure (third-party) and the tables that I will be using is in on production state. So would only mean that I have to schedule a very fast maintenance, probably 5 to 10 secs just to re-initialize the tables.

Anyway, thanks for your input, really appreciate it.


On Mon, 2007-07-30 at 23:32 -0500, Michael Glaesemann wrote:
[Please don't post the same question to many lists. Choose one. If  
you're unsure if it's the correct list for your question, ask if  
there's a more appropriate one. This question is find for -novice or - 
general. Thanks.]

On Jul 30, 2007, at 23:19 , Ronald Rojas wrote:

> And, I want to add the field name age with type integer after  
> lastname OR before the address field. How to I do that?

Can't without dumping the database, altering the schema in the dump,  
and reloading. But why does it matter? Just call the columns in the  
order you want.

Michael Glaesemann
grzm seespotcode net



==================================================================================================
Ronald Rojas
Systems Administrator
Linux Registered  User #427229
==================================================================================================

Arnold's Laws of Documentation:
	(1) If it should exist, it doesn't.
	(2) If it does exist, it's out of date.
	(3) Only documentation for useless programs transcends the
	    first two laws.


--=-nP/62sg7AJCq8OiehIo6-- From grzm@seespotcode.net Tue Jul 31 05:56:16 2007 Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id C29189FB923 for ; Tue, 31 Jul 2007 02:56:16 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 63439-08 for ; Tue, 31 Jul 2007 02:56:13 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from mtai04.charter.net (mtai04.charter.net [209.225.8.184]) by postgresql.org (Postfix) with ESMTP id A15579FB9F1 for ; Tue, 31 Jul 2007 02:56:13 -0300 (ADT) Received: from aa04.charter.net ([10.20.200.156]) by mtai04.charter.net (InterMail vM.7.08.02.00 201-2186-121-20061213) with ESMTP id <20070731055612.TMOV1443.mtai04.charter.net@aa04.charter.net>; Tue, 31 Jul 2007 01:56:12 -0400 Received: from [10.0.1.3] (really [66.188.165.91]) by aa04.charter.net with ESMTP id <20070731055612.SDGE1254.aa04.charter.net@[10.0.1.3]>; Tue, 31 Jul 2007 01:56:12 -0400 In-Reply-To: <1185859391.28634.17.camel@localhost> References: <1185855587.28634.6.camel@localhost> <7F69A56D-27E8-43EE-BD1C-AB52C042B533@seespotcode.net> <1185859391.28634.17.camel@localhost> Mime-Version: 1.0 (Apple Message framework v752.2) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <3345E320-08CF-465E-93AC-DAFBD59AA35C@seespotcode.net> Cc: pgsql-general@postgresql.org Content-Transfer-Encoding: 7bit From: Michael Glaesemann Subject: Re: [NOVICE] alter table table add column Date: Tue, 31 Jul 2007 00:56:11 -0500 To: Ronald Rojas X-Mailer: Apple Mail (2.752.2) X-Chzlrs: 0 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200707/1191 X-Sequence-Number: 117792 On Jul 31, 2007, at 0:23 , Ronald Rojas wrote: > Yes I know that procedure but I would like to insert in between > because I have at third party software that will call the said > schema and one of its dependencies with the mapping is it should > have the correct order with what the receiving end will be use for > the mapping. And in this case, I can't modify the receiving > structure (third-party) and the tables that I will be using is in > on production state. So would only mean that I have to schedule a > very fast maintenance, probably 5 to 10 secs just to re-initialize > the tables. Another option would be to use views to change the column order, which would work for selects. I believe you could create rules for insert and update as well, if necessary. Perhaps this would be a solution to your problem. Michael Glaesemann grzm seespotcode net From olly@lfix.co.uk Tue Jul 31 06:25:59 2007 Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 949A29FB9A0 for ; Tue, 31 Jul 2007 03:25:59 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 75309-06 for ; Tue, 31 Jul 2007 03:25:56 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from cerberus.lfix.co.uk (lfix.demon.co.uk [80.177.205.209]) by postgresql.org (Postfix) with ESMTP id 974DE9FB98F for ; Tue, 31 Jul 2007 03:25:56 -0300 (ADT) Received: from [192.168.8.1] by cerberus.lfix.co.uk with esmtp (Exim 4.63) (envelope-from ) id 1IFlB3-00055N-Hq for pgsql-novice@postgresql.org; Tue, 31 Jul 2007 07:25:53 +0100 Subject: Re: alter table table add column From: Oliver Elphick To: pgsql-novice In-Reply-To: <1185855587.28634.6.camel@localhost> References: <1185855587.28634.6.camel@localhost> Content-Type: text/plain Organization: LFIX Date: Tue, 31 Jul 2007 07:25:53 +0100 Message-Id: <1185863153.10580.92.camel@linda.lfix.co.uk> Mime-Version: 1.0 X-Mailer: Evolution 2.10.1 Content-Transfer-Encoding: 7bit X-LFIX-MailScanner: Found to be clean X-LFIX-MailScanner-From: olly@lfix.co.uk X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.232 tagged_above=0 required=5 tests=AWL=0.231, BAYES_50=0.001 X-Spam-Level: X-Archive-Number: 200707/110 X-Sequence-Number: 19195 On Tue, 2007-07-31 at 12:19 +0800, Ronald Rojas wrote: > 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. It isn't possible. Nor is it really necessary, since you can ask for columns in any order in a SELECT. If you really want to do it, you need to dump the table to a new table with the columns in the desired order; delete the old table and rename the new one. Alternatively, add the new column (which will come at the end), add a new address column and set its contents to be the same as the current address column, finally drop the old address column. (This will waste space in the table.) -- Oliver Elphick olly@lfix.co.uk Isle of Wight http://www.lfix.co.uk/oliver GPG: 1024D/A54310EA 92C8 39E7 280E 3631 3F0E 1EC0 5664 7A2F A543 10EA ======================================== Do you want to know God? http://www.lfix.co.uk/knowing_god.html -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. From ronald.rojas@gmail.com Tue Jul 31 06:37:48 2007 Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 87E099FBA1C for ; Tue, 31 Jul 2007 03:37:48 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 01375-04 for ; Tue, 31 Jul 2007 03:37:45 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from rv-out-0910.google.com (rv-out-0910.google.com [209.85.198.190]) by postgresql.org (Postfix) with ESMTP id 3270A9FB9F1 for ; Tue, 31 Jul 2007 03:37:44 -0300 (ADT) Received: by rv-out-0910.google.com with SMTP id f1so444113rvb for ; Mon, 30 Jul 2007 23:37:43 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:subject:from:to:cc:in-reply-to:references:content-type:date:message-id:mime-version:x-mailer; b=qYRukE2gkksEyMLIjXOr88juxhzSthssfmqhQ40S98En3wP8ISJdpPx8NEFCoMicigxDh89+CQv/cXLjhVUlBU8wHB/zcrzI/ubp9UXCOAkHrrejmGNvkQE+O6lZsrVO/zCOFEDYiKUyUxK41a+onbCXROKPM7MO9M9hs4/OG90= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:subject:from:to:cc:in-reply-to:references:content-type:date:message-id:mime-version:x-mailer; b=o4baRu60wHtIdIQx83tvIM2s/BeR5tIZ32tueatwctrkQQu8Hv7po3ESmLCMctJyYf73V8LxaDlY60BzTsSQ7wwlRgVn8tl2lbxsuqLfKNmeR4lMdaU+S+w8LJbmPluLmgbIA3Ff+PVMoIPFxbagu4P9ocOLVBUvQGR1C9PHVho= Received: by 10.140.141.15 with SMTP id o15mr2099616rvd.1185863863806; Mon, 30 Jul 2007 23:37:43 -0700 (PDT) Received: from ?133.88.3.33? ( [203.87.136.43]) by mx.google.com with ESMTPS id 2sm6275026rvi.2007.07.30.23.37.38 (version=SSLv3 cipher=RC4-MD5); Mon, 30 Jul 2007 23:37:43 -0700 (PDT) Subject: Re: [NOVICE] alter table table add column From: Ronald Rojas To: Michael Glaesemann Cc: pgsql-general@postgresql.org In-Reply-To: <3345E320-08CF-465E-93AC-DAFBD59AA35C@seespotcode.net> References: <1185855587.28634.6.camel@localhost> <7F69A56D-27E8-43EE-BD1C-AB52C042B533@seespotcode.net> <1185859391.28634.17.camel@localhost> <3345E320-08CF-465E-93AC-DAFBD59AA35C@seespotcode.net> Content-Type: multipart/alternative; boundary="=-/c5FOEyVJ5n9YLrn66A0" Date: Tue, 31 Jul 2007 14:37:28 +0800 Message-Id: <1185863848.28634.19.camel@localhost> Mime-Version: 1.0 X-Mailer: Evolution 2.10.1 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200707/1193 X-Sequence-Number: 117794 --=-/c5FOEyVJ5n9YLrn66A0 Content-Type: text/plain Content-Transfer-Encoding: 7bit Oh yes you have a good point. But then I will still have to test insert and update on views. Thanks a lot michael! On Tue, 2007-07-31 at 00:56 -0500, Michael Glaesemann wrote: > On Jul 31, 2007, at 0:23 , Ronald Rojas wrote: > > > Yes I know that procedure but I would like to insert in between > > because I have at third party software that will call the said > > schema and one of its dependencies with the mapping is it should > > have the correct order with what the receiving end will be use for > > the mapping. And in this case, I can't modify the receiving > > structure (third-party) and the tables that I will be using is in > > on production state. So would only mean that I have to schedule a > > very fast maintenance, probably 5 to 10 secs just to re-initialize > > the tables. > > Another option would be to use views to change the column order, > which would work for selects. I believe you could create rules for > insert and update as well, if necessary. Perhaps this would be a > solution to your problem. > > Michael Glaesemann > grzm seespotcode net > > ================================================================================================== Ronald Rojas Systems Administrator Linux Registered User #427229 ================================================================================================== Arnold's Laws of Documentation: (1) If it should exist, it doesn't. (2) If it does exist, it's out of date. (3) Only documentation for useless programs transcends the first two laws. --=-/c5FOEyVJ5n9YLrn66A0 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 7bit Oh yes you have a good point. But then I will still have to test insert and update on views.

Thanks a lot michael!

On Tue, 2007-07-31 at 00:56 -0500, Michael Glaesemann wrote:
On Jul 31, 2007, at 0:23 , Ronald Rojas wrote:

> Yes I know that procedure but I would like to insert in between  
> because I have at third party software that will call the said  
> schema and one of its dependencies with the mapping is it should  
> have the correct order with what the receiving end will be use for  
> the mapping. And in this case, I can't modify the receiving  
> structure (third-party) and the tables that I will be using is in  
> on production state. So would only mean that I have to schedule a  
> very fast maintenance, probably 5 to 10 secs just to re-initialize  
> the tables.

Another option would be to use views to change the column order,  
which would work for selects. I believe you could create rules for  
insert and update as well, if necessary. Perhaps this would be a  
solution to your problem.

Michael Glaesemann
grzm seespotcode net



==================================================================================================
Ronald Rojas
Systems Administrator
Linux Registered  User #427229
==================================================================================================

Arnold's Laws of Documentation:
	(1) If it should exist, it doesn't.
	(2) If it does exist, it's out of date.
	(3) Only documentation for useless programs transcends the
	    first two laws.


--=-/c5FOEyVJ5n9YLrn66A0-- From peterachilds@gmail.com Tue Jul 31 07:54:22 2007 Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 57A949FA1E8 for ; Tue, 31 Jul 2007 04:54:22 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 18575-03 for ; Tue, 31 Jul 2007 04:54:18 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from mu-out-0910.google.com (mu-out-0910.google.com [209.85.134.188]) by postgresql.org (Postfix) with ESMTP id 46B9E9FA17C for ; Tue, 31 Jul 2007 04:54:18 -0300 (ADT) Received: by mu-out-0910.google.com with SMTP id i10so2619044mue for ; Tue, 31 Jul 2007 00:54:16 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:subject:cc:in-reply-to:mime-version:content-type:references; b=tPo3fwoxNe17yWup72E5nhqrQeK9yuvixwvsAXX1aFJGlJWYayc6FC+AeeRWokQAhX222jztQZYARiqmBc/z0hQreb/wfcNenR+I2oFO658t5rQtl+Qelud8svk9xGJnqtsuq5KpyHiDsVOkuhvbRDUENp8G0ziW1Zw9GkKojpM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:subject:cc:in-reply-to:mime-version:content-type:references; b=QMAf5KX+1K0/Qgg+As8husaU++XjYOxcOXbsxmWAiteFaCpFPWZ+8A6inP3fE/fn/GeJRnKHgGFOxRhIe1JdAmZcqOjU9x4SlryX9lxR6UB2FxxihAGLjTm24UWlY9O90GEjAeZWMvdISOVaciiEES+aTGRiZQz85c8nYgdifBY= Received: by 10.78.131.8 with SMTP id e8mr1719625hud.1185868456052; Tue, 31 Jul 2007 00:54:16 -0700 (PDT) Received: by 10.78.150.17 with HTTP; Tue, 31 Jul 2007 00:54:15 -0700 (PDT) Message-ID: Date: Tue, 31 Jul 2007 08:54:15 +0100 From: "Peter Childs" Subject: Re: [NOVICE] alter table table add column Cc: pgsql-general@postgresql.org In-Reply-To: <1185863848.28634.19.camel@localhost> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_24868_25222977.1185868455902" References: <1185855587.28634.6.camel@localhost> <7F69A56D-27E8-43EE-BD1C-AB52C042B533@seespotcode.net> <1185859391.28634.17.camel@localhost> <3345E320-08CF-465E-93AC-DAFBD59AA35C@seespotcode.net> <1185863848.28634.19.camel@localhost> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200707/1196 X-Sequence-Number: 117797 ------=_Part_24868_25222977.1185868455902 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline On 31/07/07, Ronald Rojas wrote: > > Oh yes you have a good point. But then I will still have to test insert > and update on views. > > Thanks a lot michael! > > On Tue, 2007-07-31 at 00:56 -0500, Michael Glaesemann wrote: > > On Jul 31, 2007, at 0:23 , Ronald Rojas wrote: > > Yes I know that procedure but I would like to insert in between > because I have at third party software that will call the said > schema and one of its dependencies with the mapping is it should > have the correct order with what the receiving end will be use for > the mapping. And in this case, I can't modify the receiving > structure (third-party) and the tables that I will be using is in > on production state. So would only mean that I have to schedule a > very fast maintenance, probably 5 to 10 secs just to re-initialize > the tables. > Another option would be to use views to change the column order, which would work for selects. I believe you could create rules for insert and update as well, if necessary. Perhaps this would be a solution to your problem. > Michael Glaesemanngrzm seespotcode net > > But really you should not be using select * from ... anyway, Always list your column names, That way you will aways get the columns in the order you want rather than in the order they are stored. This really belongs in a FAQ Peter. ------=_Part_24868_25222977.1185868455902 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline

On 31/07/07, Ronald Rojas <ronald.rojas@gmail.com> wrote:
Oh yes you have a good point. But then I will still have to test insert and update on views.

Thanks a lot michael!

On Tue, 2007-07-31 at 00:56 -0500, Michael Glaesemann wrote:
On Jul 31, 2007, at 0:23 , Ronald Rojas wrote:

> Yes I know that procedure but I would like to insert in between  
> because I have at third party software that will call the said  
> schema and one of its dependencies with the mapping is it should  
> have the correct order with what the receiving end will be use for  
> the mapping. And in this case, I can't modify the receiving  
> structure (third-party) and the tables that I will be using is in  
> on production state. So would only mean that I have to schedule a  
> very fast maintenance, probably 5 to 10 secs just to re-initialize  
> the tables.

Another option would be to use views to change the column order,  
which would work for selects. I believe you could create rules for  
insert and update as well, if necessary. Perhaps this would be a  
solution to your problem.

Michael Glaesemann
grzm seespotcode net


But really you should not be using select * from ... anyway,
Always list your column names, That way you will aways get the columns in the order you want rather than in the order they are stored.

This really belongs in a FAQ

Peter.
------=_Part_24868_25222977.1185868455902-- From nis@superlativ.dk Tue Jul 31 07:57:27 2007 Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 860A19FB8CE for ; Tue, 31 Jul 2007 04:57:27 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 52743-03 for ; Tue, 31 Jul 2007 04:57:20 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from ciao.gmane.org (main.gmane.org [80.91.229.2]) by postgresql.org (Postfix) with ESMTP id 7453F9FB8D9 for ; Tue, 31 Jul 2007 04:57:24 -0300 (ADT) Received: from list by ciao.gmane.org with local (Exim 4.43) id 1IFmbW-0002rh-2m for pgsql-general@postgresql.org; Tue, 31 Jul 2007 09:57:18 +0200 Received: from cpe.atm2-0-1261189.0x503fa7b2.bynxx8.customer.tele.dk ([80.63.167.178]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 31 Jul 2007 09:57:18 +0200 Received: from nis by cpe.atm2-0-1261189.0x503fa7b2.bynxx8.customer.tele.dk with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 31 Jul 2007 09:57:18 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-general@postgresql.org From: =?ISO-8859-1?Q?Nis_J=F8rgensen?= Subject: Re: alter table table add column Date: Tue, 31 Jul 2007 09:56:47 +0200 Lines: 27 Message-ID: References: <1185855587.28634.6.camel@localhost> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: cpe.atm2-0-1261189.0x503fa7b2.bynxx8.customer.tele.dk User-Agent: Thunderbird 1.5.0.12 (Windows/20070509) In-Reply-To: <1185855587.28634.6.camel@localhost> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200707/1197 X-Sequence-Number: 117798 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