I'm trying to run
alter table schema_name.table_name
ALTER COLUMN column_name TYPE varchar(256)
in Amazon Redshift, but I'm getting this error:
SQL Error [500310] [0A000]: Amazon Invalid operation: cannot alter column "column_name" of relation "table_name", target column size 256 should be greater or equal to current maximum column size 879;
I've already tried
update schema_name.table_name
set column_name = CAST(column_name AS VARCHAR(256))
and
update schema_name.table_name
set column_name = SUBSTRING(column_name, 1, 256)
in order to reduce this maximum column size of 879, but I still get the same error. I know I can work around it by creating a new VARCHAR(256) column with the same data, but is there another way?
update
to 255 rather than 256. There might be an off-by-one error. – Gordon Linoff