From: | David Andersen <mrdavidandersen(at)gmail(dot)com> |
---|---|
To: | Osvaldo Kussama <osvaldo(dot)kussama(at)gmail(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Extended ability to alter column type when empty |
Date: | 2009-02-20 21:12:42 |
Message-ID: | c6bf5b380902201312g5fcff68ao3c6e8e94bd15ab3c@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi Osvaldo,
Neat! Thanks a lot for your help!
Regards,
David
On Thu, Feb 19, 2009 at 2:56 PM, Osvaldo Kussama
<osvaldo(dot)kussama(at)gmail(dot)com>wrote:
> 2009/2/17 David Andersen <mrdavidandersen(at)gmail(dot)com>:
> > Hi,
> >
> > I am a real newbee and I hope this is the right place to post a feature
> > request.
> >
> > I am receiving data from a csv file where one column has a strange data
> > format. It would be nice if I could use Copy From with to_timestamp to
> > transform the date. As far as I know this is not possible to do in one
> step
> > (unlike MySQL I believe). I, therefore, have to first read large amounts
> of
> > CSV data into one table where the data is a char(15) column. Then create
> > another table using:
> > CREATE TABLE T (like tempT);
> >
> > ALTER TABLE T ALTER COLUMN thedate TYPE TIMESTAMP;
> >
> > However, then I run into:
> > ERROR: column "thedate" cannot be cast to type "pg_catalog.timestamp"
> >
> > This error comes even though the table is empty. Could it be an idea to
> > allow this for empty tables? Am I missing something obvious in my
> > unreasonably complicated approach?
> >
>
>
> Try:
> ALTER TABLE T ALTER COLUMN thedate TYPE TIMESTAMP USING CAST (thedate
> AS timestamp);
>
> Osvaldo
>
From | Date | Subject | |
---|---|---|---|
Next Message | Torsten Bronger | 2009-02-20 21:17:35 | Re: Getting time-dependent load statistics |
Previous Message | Angelo Astorga | 2009-02-20 20:51:23 | Compatibilidad RH enterprise 5.3 !!! |