cs411-06c-sql3 - 1 CS411 Database Systems 06c: SQL-3 DB...

Info iconThis preview shows pages 1–10. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

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

Unformatted text preview: 1 CS411 Database Systems 06c: SQL-3 DB Modification, Definition, Views 2 Why Do We Learn This? 2 3 Database Modification 4 Database Modifications A modification command does not return a result as a query does, but it changes the database in some way. There are three kinds of modifications: 1. Insert a tuple or tuples. 2. Delete a tuple or tuples. 3. Update the value(s) of an existing tuple or tuples. 5 Insertion To insert a single tuple: INSERT INTO <relation> VALUES ( <list of values> ); Example: add to Likes(drinker, beer) the fact that Sally likes Bud. INSERT INTO Likes VALUES(Sally, Bud); 6 Specifying Attributes in INSERT We may add to the relation name a list of attributes. There are two reasons to do so: 1. We forget the standard order of attributes for the relation. 2. We dont have values for all attributes, and we want the system to fill in missing components with NULL or a default value. 7 Example: Specifying Attributes Another way to add the fact that Sally likes Bud to Likes(drinker, beer): INSERT INTO Likes(beer, drinker) VALUES(Bud, Sally); 8 Inserting Many Tuples We may insert the entire result of a query into a relation, using the form: INSERT INTO <relation> ( <subquery> ); .g., INSERT INTO Beers(name) SELECT beer from Sells; 9 Example: Insert a Subquery Using Frequents(drinker, bar), enter into the new relation PotBuddies(name) all of Sallys potential buddies, i.e., those drinkers who frequent at least one bar that Sally also frequents. 10...
View Full Document

This note was uploaded on 02/17/2012 for the course CS 411 taught by Professor Winslett during the Spring '07 term at University of Illinois at Urbana–Champaign.

Page1 / 29

cs411-06c-sql3 - 1 CS411 Database Systems 06c: SQL-3 DB...

This preview shows document pages 1 - 10. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online