Re: Smaller data types use same disk space - Mailing list pgsql-general

From Marc Mamin
Subject Re: Smaller data types use same disk space
Date
Msg-id C4DAC901169B624F933534A26ED7DF310861B63C@JENMAIL01.ad.intershop.net
Whole thread Raw
In response to Re: Smaller data types use same disk space  (Merlin Moncure <mmoncure@gmail.com>)
List 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 by date:

Previous
From: Craig Ringer
Date:
Subject: Re: Full text search ts_heading strange result
Next
From: Johann Spies
Date:
Subject: Re: Full text search ts_heading strange result