Home > Software engineering >  Redshift won't change column type
Redshift won't change column type

Time:02-24

I'm trying to change a column in Redshift from varchar to integer. I've already checked and the strings are all numbers so it should force fine.

When I run:

alter table schema.table_name alter column "id" type int;

I get the following error:

ERROR: target data type "int8" is not supported [SQL State=0A000]

I've checked the Redshift documentation and just to rule out a few potentials:

  • The field is not a primary or foreign key
  • There's no compression encodings on it
  • There's no default values
  • The code is not in a transaction block

Any pointers would be amazing, thank you!

CodePudding user response:

Alter column type is for varchar types - "ALTER COLUMN column_name TYPE new_data_type -- A clause that changes the size of a column defined as a VARCHAR data type." See: https://docs.aws.amazon.com/redshift/latest/dg/r_ALTER_TABLE.html

  • Related