Re: changing field length

Поиск
Список
Период
Сортировка
От scott.marlowe
Тема Re: changing field length
Дата
Msg-id Pine.LNX.4.33.0308200929520.12206-100000@css120.ihs.com
обсуждение исходный текст
Ответ на Re: changing field length  (Jodi Kanter <jkanter@virginia.edu>)
Список pgsql-admin
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
> >
>
>


В списке pgsql-admin по дате отправления:

Предыдущее
От: Stephan Szabo
Дата:
Сообщение: Re: Explicit Cast
Следующее
От: Brian McCane
Дата:
Сообщение: Compression of text fields