In this case not an option because student id is part

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

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 CHAR(20), cid CHAR(20), grade CHAR(10), PRIMARY KEY (sid, cid), (sid, FOREIGN KEY (sid) REFERENCES Students (sid) ON DELETE CASCADE ON UPDATE NO ACTION) ENGINE=InnoDB; ENGINE=InnoDB; DROP TABLE Students; DROP TABLE Students RESTRICT; DROP TABLE Students CASCADE; Instead, what if we’d said “ON UPDATE CASCADE”? we’ CASCADE” 27 ALTER TABLE 28 Examples of ALTER TABLE Add or delete columns Add Create or destroy indexes Create Change column type Change Rename columns Rename 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.

Ask a homework question - tutors are online