SQL ALTER Statement
$count++; if($count == 1) { include "../mobilemenu.php"; } if ($count == 2) { include "../sharemediasubfolder.php"; } ?>
SQL ALTER TABLE statement. An ALTER TABLE statement is used to alter an existing table.
We can use ALTER TABLE statement to add, modify or remove columns from an existing table.
We can also use ALTER TABLE statement to add, modify or remove constraints in an existing table.
Examples:
ALTER TABLE EMPLOYEE ADD COLUMN SPOUSE_NAME VARCHAR(50)
Result: Adds a new column to EMPLOYEE table called SPOUSE_NAME.ALTER TABLE EMPLOYEE DROP COLUMN SPOUSE_NAME
Result: Removes the column SPOUSE_NAME from EMPLOYEE table.ALTER TABLE EMPLOYEE MODIFY COLUMN EMPDESIGNATION VARCHAR(100)
Result: We increased the size of EMPDESIGNATION column from 50 to 100.ALTER TABLE EMPLOYEE
ADD CONSTRAINT FKDEPARTMENT
FOREIGN KEY (DEPARTMENTID) REFERENCES DEPARTMENT(DEPARTMENTID);
Result: We added a Foreign key constraint from EMPLOYEE table to DEPARTMENT table.ALTER TABLE EMPLOYEE
ADD CONSTRAINT PKEMPNAME PRIMARY KEY (EMPNAME);
Result: We added a Primary key constraint on EMPLOYEE table.