Tuesday, 9 June 2020

The ALTER TABLE statement is used to add, delete, or modify columns in an existing table.

The ALTER TABLE statement is used to add, delete, or modify columns in an existing table.
ALTER TABLE table_name
ADD column_name datatype;
to add column
to delete column
ALTER TABLE table_name
DROP COLUMN column_name;
ALTER TABLE Customers
DROP COLUMN Email;

HOW TO ADD ONE COLUMN
ALTER TABLE `foods` ADD `HTML` VARCHAR(200) NOT NULL AFTER `type`;






to modify the datatyoe 
ALTER TABLE Persons
MODIFY Age int NOT NULL;
ALTER TABLE Persons
ADD CHECK (Age>=18);
ALTER TABLE Persons
DROP CHECK CHK_PersonAge;






ALTER TABLE Persons
modify
ADD CONSTRAINT df_City
DEFAULT 'Sandnes' FOR City;
ALTER TABLE Persons
ADD CONSTRAINT df_City
DEFAULT 'Sandnes' FOR City;






No comments:

Post a Comment