HiveBrain v1.2.0
Get Started
← Back to all entries
snippetModerate

How to increase column size in Redshift database tables?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
tablescolumnredshiftsizedatabaseincreasehow

Problem

In oracle, I can:

Alter table table_name
modify column_name datatype;


Is this possible in a redshift database?

Solution

Recently AWS added support for increasing the varchar column size,


Alter a VARCHAR Column To conserve storage, you can define a table
initially with VARCHAR columns with the minimum size needed for your
current data requirements. If later you need to accommodate longer
strings, you can alter the table to increase the size of the column.
To protect existing data, you can't decrease column size.


The following example changes the size of the EVENTNAME column to
VARCHAR(300).

alter table event alter column eventname type varchar(300);




The following command fails because it attempts to decrease the size
of the EVENTNAME column.

alter table event alter column eventname type varchar(100);


link

Code Snippets

alter table event alter column eventname type varchar(300);
alter table event alter column eventname type varchar(100);

Context

StackExchange Database Administrators Q#171500, answer score: 12

Revisions (0)

No revisions yet.