SQL ALTER Table - Javatpoint
SQL ALTER Table - Javatpoint
Any user can also change the name of the table using this statement.
The above syntax only allows you to add a single column to the existing table. If you want to add more
than one column to the table in a single SQL statement, then use the following syntax:
Table: Cars
Suppose, you want to add the new column Car_Model in the above table. For this, you have to
type the following query in the SQL:
Table: Employee
Suppose, you want to add two columns, Emp_ContactNo. and Emp_EmailID, in the above
Employee table. For this, you have to type the following query in the SQL:
This statement will add Emp_ContactNo. and Emp_EmailID columns to the Employee table.
This syntax only allows you to modify a single column of the existing table. If you want to modify more
than one column of the table in a single SQL statement, then use the following syntax:
Table: Cars
Suppose, you want to modify the datatype of the Car_Color column of the above table. For this,
you have to type the following query in the SQL:
Table: Employee
Suppose, you want to modify the datatypes of two columns Emp_ContactNo. and Emp_EmailID
of the above Employee table. For this, you have to type the following query in the SQL:
Table: Cars
Suppose, you want to delete the Car_Color column from the above table. For this, you have to
type the following query in the SQL:
Let's check using the following statement that the Car_Color column is deleted from the table or
not:
Table: Employee
Suppose, you want to delete the Emp_Salary and Emp_City column from the above Employee
table. For this, you have to type the following two different queries in the SQL:
Table: Cars
Suppose, you want to change the name of the Car_Color column of the above Cars table. For
this, you have to type the following query in the SQL:
This statement will change the name of a column of the Cars table. To see the changes, you have to
type the following query:
Table: Cars
Table: Employee
Suppose, you want to change the name of the Emp_City column of the above Employee table.
For this, you have to type the following query in the SQL:
This statement will change the name of a column of the Employee table. To see the changes, you have
to type the following query:
Table: Employee
← Prev Next →
Preparation
Trending Technologies
B.Tech / MCA