pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: scott.marlowe <scott.marlowe@ihs.com>
To: Jodi Kanter <jkanter@virginia.edu>
Cc: Bruno Wolff III <bruno@wolff.to>
Cc: Gaetano Mendola <mendola@bigfoot.com>
Cc: pgsql-admin@postgresql.org
Subject: Re: changing field length
Date: Wed, 20 Aug 2003 09:48:39 -0600 (MDT)
Message-ID: <Pine.LNX.4.33.0308200929520.12206-100000@css120.ihs.com> (raw)
In-Reply-To: <3F4390C2.6050106@virginia.edu>

As always, there's more than one way to skin a cat...

Create a new table and insert into it:

create newtable (field newdef, field2 newdef);
insert into 
  newtable (
    select oldfield, 
    oldfield2 from oldtable
  );

Create it on the fly with Postgresql casting shortcuts:
select 
  field1::newtype, 
  field2::newtype, 
  field3, 
  field4 
into 
  newtable 
from 
  oldtable;

Create it on the fly with ANSI style casting:
select 
  cast(field1 as newtype), 
  cast(field2 as newtype),
  field3, 
  field4 
into 
  newtable 
from 
  oldtable;


On Wed, 20 Aug 2003, Jodi Kanter wrote:

> Ok. so for now I want to return to where I started. so I renamed the 
> table and regenerated my original table with the fields in the order 
> that I like. I cannot just do a
> insert into table select * from other_table;
> because the fields are in a different order.
> Can I do this by listing the fields in my insert in the order in which I 
> want them placed?
> Thanks
> Jodi
> 
> Bruno Wolff III wrote:
> 
> >On Wed, Aug 20, 2003 at 10:49:08 -0400,
> >  Jodi Kanter <jkanter@virginia.edu> wrote:
> >
> >>can I now make this field not null?
> >>
> >>is it possible to move a field up in a table? now that I have done this 
> >>
> >
> >Currently, not without recreating the table. There was some discussion
> >about that a few months ago, but nothing is happening in 7.4 on that
> >front. Maybe in 7.5 there will be a way to change the column order,
> >but don't count on it.
> >
> >---------------------------(end of broadcast)---------------------------
> >TIP 6: Have you searched our list archives?
> >
> >               http://archives.postgresql.org
> >
> 
> 




view thread (13+ messages)

Message-ID: <Pine.LNX.4.33.0308200929520.12206-100000@css120.ihs.com>
Permalink:  ../Pine.LNX.4.33.0308200929520.12206-100000@css120.ihs.com/
Also on:    postgresql.org/message-id/Pine.LNX.4.33.0308200929520.12206-100000@css120.ihs.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: scott.marlowe@ihs.com, jkanter@virginia.edu, bruno@wolff.to, mendola@bigfoot.com
  Subject: Re: changing field length
  In-Reply-To: <Pine.LNX.4.33.0308200929520.12206-100000@css120.ihs.com>
  References: <3F4390C2.6050106@virginia.edu> <Pine.LNX.4.33.0308200929520.12206-100000@css120.ihs.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