Redshift Alter Table

RazorSQL provides an Alter Table Tool for Amazon Redshift databases. The tool generates and executes the DDL specific to the alter table command such as DDL for adding columns, creating primary keys, etc.

The AWS Redshift alter table tool supports the following types of alter table commands:

Add Column - Adds a column to a table
Add Primary Key - Adds a primary key to a table
Add Foreign Key - Adds a foreign key to a table
Add Constraint - Adds a check constraint to a table
Change Column Type - Changes the data type of a column
Drop Column - Drops a column from a table
Drop Constraint - Drops a check constraint from a table
Drop Primary Key - Drops a primary key from a table
Drop Foreign Key - Drops a foreign key from a table
Rename Table - Renames a table
Rename Column - Renames a column

Listed below are some sample SQL statements generated by the Redshift Alter Table Tool.

ALTER TABLE department ADD newcol char NOT NULL

ALTER TABLE department ADD PRIMARY KEY (dept_id)

ALTER TABLE department ADD FOREIGN KEY (location_id) REFERENCES locations(location_id)

ALTER TABLE department RENAME COLUMN dept_id TO department_id

ALTER TABLE department RENAME TO departments

Redshift Alter Table