arrow_backwardBack to Amazon Redshift code examples

Amazon Redshift Full Alter Table Example

A Amazon Redshift example for changing, adding, and removing columns for an existing table
ALTER TABLE
  "users"
ADD
  COLUMN "last_name" varchar(255) NULL COMMENT 'Also known as family name';
ALTER TABLE
  "users" DROP COLUMN "favorite_color";
ALTER TABLE
  "users"
ALTER COLUMN
  "first_name" TYPE varchar(255);
ALTER TABLE
  "users"
ALTER COLUMN
  "birthdate" DROP NOT NULL;
ALTER TABLE
  "users"
ALTER COLUMN
  "best_friend"
SET
  DEFAULT 'The Kid Next Door';
COMMENT ON COLUMN "users"."first_name" IS 'Don''t make this column shorter, some people have long names!';

Using Beekeeper Studio?

Beekeeper Studio is a free and open source database manager for Windows, Mac, and Linux.

This feature is baked right in, so there's no need to manually type SQL every time. Access table column editing by right-clicking on a table in the sidebar and clicking 'View Structure'.

Download Beekeeper Studio