How to increase column size in Redshift database tables

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, or TEXT32K.
  • 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, or FOREIGN KEY.
  • You can not alter columns inside a multi-statement block (BEGIN...END).

SQL to increase the size

ALTER TABLE <table_name> ALTER COLUMN <column_name> type varchar(300);

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);
5 1 vote
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments