How to Add a Column in Redshift
Adding a column in Redshift involves using the ALTER TABLE
command. The typical syntax is as follows:
ALTER TABLE promotions ADD expiry_date DATE;
Redshift supports the following data types:
- SMALLINT (INT2)
- INTEGER (INT, INT4)
- BIGINT (INT8)
- DECIMAL (NUMERIC)
- REAL (FLOAT4)
- DOUBLE PRECISION (FLOAT8)
- BOOLEAN (BOOL)
- CHAR (CHARACTER)
- VARCHAR (CHARACTER VARYING)
- DATE
- TIMESTAMP
Here's an example of adding a string (varchar) column with a not null constraint:
ALTER TABLE users ADD nickname VARCHAR NOT NULL;
Adding a boolean column with a default value:
ALTER TABLE users ADD active BOOLEAN DEFAULT TRUE;
Previous
How to Duplicate a TableShared queries and folders ✅ Version history ✅ One-click connection to Redshift ✅
Get more done, together, with PopSQL and Redshift