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 <[EMAIL PROTECTED]> 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
> >
> 
> 


---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Reply via email to