The Alter Command for Redshift

Here I’ll just log all the scenarios where I had to use the alter command


Rename column


Syntax:


alter table <table_name>
rename column <old column name> to <new column name>


Change the datatype


Redshift only supports changing the size of the varchar column. Every other data type change you’ll need to look for a work around.


alter table <table_name> 
alter column <column_name> type varchar(<new size>);


Change the table name


Syntax:


alter table <table_name>
rename to <new_name>;


Sources:




Enjoy Reading This Article?

Here are some more articles you might like to read next:

  • 6 months a data engineer…
  • Failing forward; Lessons from Airflow error alerts.
  • Learning while working.
  • Can Machine Learning Help Predict Heart Disease? A Data Science Exploration
  • Predicting House Prices; MLR vs RFR