tags:

views:

154

answers:

1

I'm trying to change the datatype of a column to varchar but get the following error

ERROR:  syntax error at or near "type" at character 40

My code looks as follows

alter table n_logs alter column action type varchar(100);

I'm running PostgreSQL 7.4.13 (Yeah, I know I need to upgrade)

+2  A: 

I don't think you can do that: http://www.postgresql.org/docs/7.4/interactive/ddl-alter.html

You should split it into 3 steps

  1. add new column
  2. copy values from 1st column to 2nd
  3. drop old column
andersonbd1