This preview shows page 1. Sign up to view the full content.
Unformatted text preview: (In this
case, not an option because student ID is part of PK for Enrolled and cannot
be null.) 25
25 How SQL Handles the Options 26 DROP TABLE CREATE TABLE Enrolled ( sid
PRIMARY KEY (sid, cid),
FOREIGN KEY (sid) REFERENCES Students
ON DELETE CASCADE
ON UPDATE NO ACTION)
ENGINE=InnoDB; DROP TABLE Students;
DROP TABLE Students RESTRICT;
DROP TABLE Students CASCADE; Instead, what if we’d said “ON UPDATE CASCADE”?
CASCADE” 27 ALTER TABLE 28 Examples of ALTER TABLE Add or delete columns
Create or destroy indexes
Change column type
Change table type
Change ALTER TABLE Students
ADD COLUMN maiden-name CHAR(10);
maiden(What happens to existing tuples?)
tuples?) ALTER TABLE Students RENAME TO Undergrads;
(Privileges must be reassigned.) ALTER TABLE Students ENGINE = InnoDB;
InnoDB; 29 30 Examples of ALTER TABLE SQL Query ALTER TABLE Students DROP Phone, DROP Lot;
(Deletes columns called Phone and Lot.) SELE...
View Full Document
This note was uploaded on 10/15/2012 for the course CSE 4503 taught by Professor Edallen during the Fall '12 term at Mississippi State.
- Fall '12