Sometimes you may need to add column in Redshift table. In this article, we will look at how to add column in Redshift.
How To Add Column in Redshift
You can add column in Redshift using ALTER TABLE … ADD statement.
Here is the syntax for ALTER TABLE statement to add column in Redshift
alter table table_name add column_definition
In the above SQL query, you need to specify the table name, and new column’s full definition.
Also read : How to Truncate Table in Redshift
For example, here is the SQL query to add column sale to orders table.
alter table orders add sale int;
You can also specify column constraints while adding a new column. Here is the SQL query to add sale column to orders table, with default value 0.
alter tables orders add sale int default 0;
Also read : How to Rename Table in Redshift
If you want to add multiple columns in Redshift, you need to add their column definitions in a comma-separated manner.
Here is the SQL query to add columns sale and product to orders table.
alter table orders add sale int, product varchar(100);