8.2. ALTER TABLE

Synopsis

  1. ALTER TABLE name RENAME TO new_name
  2. ALTER TABLE name ADD COLUMN column_name data_type [ COMMENT comment ] [ WITH ( property_name = expression [, ...] ) ]
  3. ALTER TABLE name DROP COLUMN column_name
  4. ALTER TABLE name RENAME COLUMN column_name TO new_column_name

Description

Change the definition of an existing table.

Examples

Rename table users to people:

  1. ALTER TABLE users RENAME TO people;

Add column zip to the users table:

  1. ALTER TABLE users ADD COLUMN zip varchar;

Drop column zip from the users table:

  1. ALTER TABLE users DROP COLUMN zip;

Rename column id to user_id in the users table:

  1. ALTER TABLE users RENAME COLUMN id TO user_id;

See Also

CREATE TABLE