pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Daryl Richter <daryl@brandywine.com>
To: fmiddleton@verizon.net
Cc: pgsql-sql@postgresql.org
Subject: Re: changing a column's position in table, how do you do that
Date: Wed, 28 Sep 2005 15:38:05 -0400
Message-ID: <433AF11D.801@brandywine.com> (raw)
In-Reply-To: <4339CD1B.10404@verizon.net>
References: <4339CD1B.10404@verizon.net>

Ferindo Middleton Jr wrote:
> Is there a way to change the position attribute of a column in a table? 
> I have data that I need to import into various tables in my db on a 
> consistent basis... I usually us e the COPY ... FROM query but I can't 
> control the -order- of the fields my client dumps the data so I would 
> like to be able to change the position the columns in my table to be 
> able to better align the data to be imported with the format of my 
> table. I was thinking I could do something like "ALTER TABLE ALTER 
> COLUMN ... " or something like that to change the columns position in 
> the table but I can't figure out how.
> 
> Ferindo
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 6: explain analyze is your friend

Constantly changing the column order of a table doesn't make sense (and 
is a pain!).

I would suggest setting up a temporary staging table with generic column 
names to take in the input data and then using SQL to move it into its 
permanent location.

-- 
Daryl

"We want great men who, when fortune frowns, will not be discouraged."
     -- Colonel Henry Knox, 1776




view thread (5+ messages)  latest in thread

Message-ID: <433AF11D.801@brandywine.com>
Permalink:  ../433AF11D.801@brandywine.com/
Also on:    postgresql.org/message-id/433AF11D.801@brandywine.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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: daryl@brandywine.com, fmiddleton@verizon.net
  Subject: Re: changing a column's position in table, how do you do that
  In-Reply-To: <433AF11D.801@brandywine.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