ALTER TABLE


 

SQLite: ALTER TABLE Statementn

This SQLite tutorial explains how to use the SQLite ALTER TABLE statement to add a column, modify a column, drop a column, rename a column or rename a table (with syntax and examples).

 

Description:
The SQLite ALTER TABLE statement is used to add, modify, or drop/delete columns in a table. The SQLite ALTER TABLE statement is also used to rename a table.

 

Syntax:

ALTER TABLE – Add column in table Syntax:

 

Parameters or Arguments:

table_name

The name of the table to modify.

new_column_name

The name of the new column to add to the table.

column_definition

The datatype and definition of the column (NULL or NOT NULL, etc).

 

ALTER TABLE – Drop column in table Syntax:

 

Parameters or Arguments:

table_name

The name of the table to modify.

column_name

The name of the column to drop/delete.

 

ALTER TABLE – Rename table Syntax:

 

Parameters or Arguments:

table_name

The name of the table to modify.

new_table_name

The new table name.

 

Examples:

The Following SQLite statement alter the employees which add’s a new column “DateOfBirth” to the table: