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.
  • When the Explanation Is the Target: Building a Reproducible XAI Robustness Benchmark
  • Grounded by Design: Building a Self-Hosted Assistant for Health-Supply Planning