Session6-a

Session6-a - Session 6: SQL DML (CH-4) CSCI-585, Cyrus...

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

View Full Document Right Arrow Icon
Session 6: SQL DML (CH-4) CSCI-585 , Cyrus Shahabi (Some example queries, but you need to go read the book and do more exercise on your own, not everything is covered!) Emp (SS#, name, age, salary, dno) Dept (dno, dname, floor, mgrSS#) SQL provides commands to change the state of database: insert , delete , and update . Insert has two different syntax: 1. insert into rel-name values value list 2. insert into rel-name select To illustrate, assume the existence of two relations: register(sid, sname, paid, course#) and CSCI585(sid,sname). If Joe and Bob register for csci585 without having paid: insert into register values
Background image of page 1

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

View Full DocumentRight Arrow Icon
(666-66-6666, `Joe', No, 585) (777-77-7777, `Bob', No, 585) To insert all CSCI585 student into CSCI585 relation who have paid: insert into CSCI585 select sid, name from register r where r.paid = `yes' and r.course#=585 Note that the target list of the select command must confirm to the schema of CSCI585 Delete has the following syntax: delete rel-name where qualification
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 7

Session6-a - Session 6: SQL DML (CH-4) CSCI-585, Cyrus...

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

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