SQL ADD Keyword (Adding Columns to Tables)

The ADD keyword in SQL, used within the ALTER TABLE statement, allows you to add new columns to an existing table. This is a fundamental way to modify your database schema and add new attributes to your data.



Adding Columns with ALTER TABLE

Adding a Column to a Table

The ADD keyword is used to specify the new column's name and its data type within the ALTER TABLE statement. It's important to carefully consider the appropriate data type for your new column to ensure data integrity.

Syntax

ALTER TABLE table_name
ADD column_name data_type;
      

Example: Adding an Email Address Column

This example adds an 'Email' column (type VARCHAR(255)) to the 'Customers' table. This assumes a table named 'Customers' already exists.

Syntax

ALTER TABLE Customers
ADD Email varchar(255);
      
Output

A new column named 'Email' is added to the 'Customers' table. Each row in the table now has a new 'Email' column, initially containing NULL values unless a default value is specified.