SQL COLUMN Keyword
The COLUMN keyword is used with ALTER TABLE to modify the structure of an existing table. This includes changing a column’s data type or deleting a column.
SQL ALTER COLUMN Syntax
The ALTER COLUMN command is used to change the data type of a column in a table.
ALTER TABLE table_name
ALTER COLUMN column_name new_data_type
SQL ALTER COLUMN Example
MySQL / SQL Server / Oracle / MS Access:
This example changes the data type of the column EngineCode in the Vehicles table to a string with a maximum length of 10 characters.
ALTER TABLE Vehicles
ALTER COLUMN EngineCode VARCHAR(10)
Note: SQLite including the TechKubo playground does not support the ALTER COLUMN syntax. To change a column’s data type in SQLite you must recreate the table.
SQL DROP COLUMN Syntax
The DROP COLUMN command is used to remove a column from an existing table.
ALTER TABLE table_name
DROP COLUMN column_name
SQL DROP COLUMN Example
MySQL / SQL Server / Oracle / MS Access:
This example removes the column EngineCode from the Vehicles table.
ALTER TABLE Vehicles
DROP COLUMN EngineCode
Note: SQLite including the TechKubo playground does not support DROP COLUMN using ALTER TABLE. To drop a column in SQLite you must recreate the table without the unwanted column.