It is only possible to alter VARCHAR
columns, and only under the following circumstances:
- You can not alter a column with compression encodings
BYTEDICT
,RUNLENGTH
,TEXT255
, orTEXT32K
. - You can not decrease the size less than the maximum size of existing data.
- You can not alter columns with default values.
- You can not alter columns with
UNIQUE
,PRIMARY KEY
, orFOREIGN KEY
. - You can not alter columns inside a multi-statement block
(BEGIN...END)
.
SQL to increase the size of (Redshift Alter Table)
It’s very simple to perform a Redshift Alter Table
command to alter the column length, or alter the column varchar length:
ALTER TABLE <table_name> ALTER COLUMN <column_name> type varchar(300);
The above command will increase column size to Redshift tables and alter the column length, or column size as required.
There is no TEXT
column size in Redshift, so you can go to a maximum of 65535
, or simply specify the max
alias.
For example:
ALTER TABLE <table_name> ALTER COLUMN <column_name> type varchar(65535);
-- or
ALTER TABLE <table_name> ALTER COLUMN <column_name> type varchar(max);