|
Home > Archive > PostgreSQL SQL > April 2005 > About "Alter table... alter column.. TYPE ... "
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
About "Alter table... alter column.. TYPE ... "
|
|
| Ying Lu 2005-04-18, 8:24 pm |
| Hello,
To alter table column from varchar(32) to date. "Alter table" command
does not seem to work:
alter table test alter column col type date ;
ERROR: column "col1" cannot be cast to type "date"
Tks,
Emi
---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings
| |
| Rod Taylor 2005-04-18, 8:24 pm |
| > To alter table column from varchar(32) to date. "Alter table" command
> does not seem to work:
>
> alter table test alter column col type date ;
> ERROR: column "col1" cannot be cast to type "date"
Alter table will not automatically throw away information. That is, in
cases where it believes you may lose data, it will not perform it.
That said, you can coax it into doing so.
ALTER TABLE test ALTER COLUMN col TYPE date USING CAST(col AS date);
USING is an arbitrary expression capable of doing most things you can do
in an UPDATE.
--
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?
http://www.postgresql.org/docs/faq
|
|
|
|
|