ALTER TABLE

The ALTER TABLE statement lets you redefine a table’s structure. It lets you add or delete columns and constraints. The syntax is similar to the syntax used to define parts of a table except this statement begins with ALTER TABLE. For example, the following script creates a Salary table. Successive ALTER TABLE statements then add additional fields and constraints and drop the original EmployeeName field:

 # Create the Salary table. CREATE TABLE Salary ( EmployeeName VARCHAR(100) NOT NULL ); # Add the FirstName field with a NOT NULL constraint. ALTER TABLE Salary ADD FirstName VARCHAR(50) NOT NULL DEFAULT ''; # Add the LastName field with a NOT NULL constraint. ALTER TABLE Salary ADD LastName VARCHAR(50) NOT NULL DEFAULT ''; # Drop ...

Get Visual Basic® .NET Database Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.