modify columns in an existing table. The ALTER
The CREATE DATABASE statement is used to
TABLE statement is also used to add and drop various
create a new SQL database.
constraints on an existing table.
Syntax:
ALTER TABLE - ADD Column
CREATE DATABASE databasename;
To add a column in a table, use the following syntax:
CREATE DATABASE testDB;
ALTER TABLE table_name
ADD column_name datatype;
The DROP DATABASE statement is used to drop ALTER TABLE Customers
an existing SQL database. ADD Email varchar (255);
Syntax: ALTER TABLE - DROP COLUMN
DROP DATABASE databasename; To delete a column in a table, use the following syntax
(notice that some database systems don't allow deleting a
DROP DATABASE testDB; column):
ALTER TABLE table_name
The CREATE TABLE statement is used to create a DROP COLUMN column_name;
new table in a database. ALTER TABLE Customers
Syntax: DROP COLUMN Email;
CREATE TABLE table_name ( ALTER TABLE - MODIFY COLUMN
column1 datatype, To change the data type of a column in a table, use the
column2 datatype, following syntax:
column3 datatype,
.... ALTER TABLE table_name
); MODIFY COLUMN column_name datatype;
CREATE TABLE Persons ( ALTER TABLE Persons
PersonID int, ADD DateOfBirth date;
LastName varchar(255),
DROP COLUMN
FirstName varchar(255),
Address varchar(255), Example
City varchar(255)
Next, we want to delete the column named
);
"DateOfBirth" in the "Persons" table.
We use the following SQL statement:
The DROP TABLE statement is used to drop an
Example
existing table in a database.
ALTER TABLE Persons
Syntax:
DROP COLUMN DateOfBirth;
DROP TABLE table_name;
DROP TABLE Shippers;