Re: Smaller data types use same disk space

Поиск
Список
Период
Сортировка
От Marc Mamin
Тема Re: Smaller data types use same disk space
Дата
Msg-id C4DAC901169B624F933534A26ED7DF310861B63C@JENMAIL01.ad.intershop.net
обсуждение исходный текст
Ответ на Re: Smaller data types use same disk space  (Merlin Moncure <mmoncure@gmail.com>)
Список pgsql-general
> > Has there been any discussion of providing the ability to re-order
> > table columns through an ALTER TABLE command?  I would love to see
> > this; when I add in a new column, I often want to put it next to
> > something just to be more visually appealing when I'm running ad-hoc
> > queries.  It could potentially address this problem as well.
>
> see: http://wiki.postgresql.org/wiki/Alter_column_position
> as well as extensive discussion in the archives.
>
> merlin


Hello,

actually columns position can be changed with alter table using
ALTER TYPE ... USING. All constraints, indexes and possible serials
naturally still need to be handled as well

However, I'm not sure that this alternative may have any advantage
upon the method described on the wiki page.

  create temp table test (a serial, b varchar);
  insert into test (b) values ('a'),('b');

  create index a_i on test(a);
  create index b_i on test(b);
  create index ab_i on test(a,b);

  alter table test
    ALTER a TYPE varchar USING b,
    ALTER b TYPE int     USING a;

  alter table test  rename b to _b;
  alter table test  rename a to b;
  alter table test  rename _b to a;

  select * from test;

  \d+ test

Marc Mamin




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

Предыдущее
От: Craig Ringer
Дата:
Сообщение: Re: Full text search ts_heading strange result
Следующее
От: Johann Spies
Дата:
Сообщение: Re: Full text search ts_heading strange result