MySQL part 5
MySQL part 5
ALTER Table
After creating a table we may realize that we
need to add/remove an attribute or to modify
the datatype of an existing attribute or to add
constraint in attribute.
In all such cases, we need to change or alter
the structure of the table by using the ALTER
TABLE statement.
EXAMPLE
Consider the following STUDENT table:
SYNTAX
ALTER TABLE table_name ADD FOREIGN
KEY(attribute name) REFERENCES
referenced_table_name (attribute name);
Create table activity
( activityid varchar(5) primary key,
activityname varchar(20),
srno int(4),
score int(3));
EXAMPLE
DROP TABLE STUDENT;
Drop a DataBase
SYNTAX
DROP DATABASE database_name;
EXAMPLE
DROP DATABASE SCHOOL;