Skip to main content

Alter

Rename a Table

Change the name of a table

ALTER TABLE users
RENAME TO customers;

Add a New Column

Add a new column to an existing table

ALTER TABLE users
ADD COLUMN phone_number VARCHAR(15) UNIQUE;

Drop a Column

Remove a column from a table

ALTER TABLE users
DROP COLUMN phone_number;

Rename a Column

Rename an existing column

ALTER TABLE users
RENAME COLUMN name TO full_name;

Change a Column's Data Type

Change the data type of a column

ALTER TABLE users
ALTER COLUMN age TYPE BIGINT;