SQL ALTER TABLE syntax and example tutorial
After the alter table statement allows you to change the structure of a TABLE, it is created. Address terms that can be added to a new column. Existing columns may be deleted from the Drop clause table.
The syntax of the alter table statement is as follows:
Alter table table_name
ADD column_name data_type
Alter table table_name
Drop column column_name
Note: The alter table statement is not in the ANSI/ISO standard. This means that all SQL statements implement different terms and command syntax in business dialects.
Example #1
Alter table Orders
ADD Quantity SMALLINT
In this example, add a column to the order table by specifying the name and Data Type of the new column.
Example #2
Alter table EmployeeAddressTable
ADD Description VARCHAR (20) DEFAULT 'usa' NOT NULL
In this example, a column named "Description" is added to the "EmployeeAddressTable" table. We also add a reserved word that is not NULL. valid data is required to be added to this column and a default value is specified.
Example #3
Alter table AntiqueOwners drop column State