SQL Add Column | Add Column in SQL - sql - sql tutorial - learn sql

- A table definition modifies by altering, adding, or dropping columns & constraints, reassigning and rebuilding partitions, or disabling or enabling constraints and triggers.
- The statement ALTER TABLE, which is also used to add & drop various constraints on an existing table.
- Sometimes we wish to add a column to a table.
- This can be achieved in SQL.
- we specify that we want to alter the table structure via the ALTER TABLE command, followed by the ADD command to tell the RDBMS that we want to add a column.
The SQL syntax for ALTER TABLE Add Column is,
ALTER TABLE "table_name"
ADD "column_name" "Data Type";
For example, assuming our starting point is the Employee table created in the CREATE TABLE section:

Table Employee
Column Name | Data Type |
---|---|
First_Name | char(50) |
Last_Name | char(50) |
Address | char(50) |
City | char(50) |
Country | char(25) |
Birth_Date | datetime |
- Our goal is to add or insert a column called "Gender":

sql tutorial , pl sql tutorial , mysql tutorial , oracle tutorial , learn sql , sql server tutorialMySQL:
MySQL:
ALTER TABLE Employee ADD Gender char(1);
Tags : sql tutorial , pl sql tutorial , mysql tutorial , oracle tutorial , learn sql , sql server tutorialOracle:
Oracle:
ALTER TABLE Employee ADD Gender char(1);
SQL Server:
ALTER TABLE Employee ADD Gender char(1);
- The resulting table structure is:
Table Employee
Column Name | Data Type |
---|---|
First_Name | char(50) |
Last_Name | char(50) |
Address | char(50) |
City | char(50) |
Country | char(25) |
Birth_Date | datetime |
Gender | char(1) |
Note: The new column Gender becomes the last column in the Employee table.
- Similarly, it is also possible to add multiple columns. For example, if we want to add a column called "Emp_id" & another column called "Salary", we will type the following:

Tags : sql tutorial , pl sql tutorial , mysql tutorial , oracle tutorial , learn sql , sql server tutorialMySQL:
MySQL:
ALTER TABLE Employee ADD (Emp_id char(30), Salary char(20) );
sql tutorial , pl sql tutorial , mysql tutorial , oracle tutorial , learn sql , sql server tutorialOracle:
Oracle:
ALTER TABLE Employee ADD (Emp_id char(30), Salary char(20) );
SQL Server:
ALTER TABLE Employee ADD (Emp_id char(30), Salary char(20) );
- The table now becomes:
Table Employee
Column Name | Data Type |
---|---|
First_Name | char(50) |
Last_Name | char(50) |
Address | char(50) |
City | char(50) |
Country | char(25) |
Birth_Date | datetime |
Gender | char(1) |
Emp_id | char(30) |
Salary | char(20) |