| From: | Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com> |
|---|---|
| To: | Ron Johnson <ron(dot)l(dot)johnson(at)cox(dot)net> |
| Cc: | PgSQL Novice ML <pgsql-novice(at)postgresql(dot)org> |
| Subject: | Re: Modyifying a column's datatype |
| Date: | 2003-09-03 22:15:27 |
| Message-ID: | 20030903151433.U11944-100000@megazone.bigpanda.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-novice |
On Wed, 3 Sep 2003, Ron Johnson wrote:
> On Wed, 2003-09-03 at 14:56, Louise Cofield wrote:
> > Greetings
> >
> > It looks to me as if there is no way to alter the datatype of a table
> > column, as in from timestamp to varchar. Am I right? (I will cry if
> > Im right.) L.
> >
> > It appears that I must drop and then re-create the table structure,
> > with my new column datatype, in order to keep the columns in the
> > current order true?
>
> There are references to this all throughout the archives.
>
> begin;
> alter table foo add column bar varchar;
> update foo set bar = cast(sniffle as varchar);
> alter table foo drop column sniffle;
> alter table foo rename column bar to sniffle;
> commit;
Just to be clear, however, that won't keep the columns in the same order
(although in general, that shouldn't be relied on anyway).
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Ron Johnson | 2003-09-03 22:37:19 | Re: Lock and read next |
| Previous Message | Juan Francisco Diaz | 2003-09-03 22:02:01 | Using NOT IN |