Week 9 - 9/9/2009 1 Advanced SQL Advanced SQL Using and...

Info iconThis preview shows pages 1–6. 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
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 9/9/2009 1 Advanced SQL Advanced SQL Using and manipulating the data you stored Week 9 Checkpoint Checkpoint What we have learnt so far Why database design The tool for capturing business rules (ERD) Defining relations (normalization) Last session The SQL commands DDL and DML This session 7-2 This session More advanced DB operations 9/9/2009 2 Relational Set Operators Relational Set Operators UNION INTERSECT MINUS Work properly if relations are union- compatible Names of relation attributes must be the same and their data types must be identica 7-3 and their data types must be identical UNION UNION Example query: SELECT CUS_LNAME, CUS_FNAME, CUS_INITIAL, CUS_AREACODE, CUS_PHONE FROM CUSTOMER UNION SELECT CUS_LNAME, CUS_FNAME, 7-4 CUS_INITIAL, CUS_AREACODE, CUS_PHONE FROM CUSTOMER_2; 9/9/2009 3 UNION (contd) UNION (contd) UNION query results: 7-5 UNION ALL UNION ALL Example query: SELECT CUS_LNAME, CUS_FNAME, CUS_INITIAL, CUS_AREACODE, CUS_PHONE FROM CUSTOMER UNION ALL SELECT CUS_LNAME, CUS_FNAME, CUS INITIAL CUS AREACODE 7-6 CUS_INITIAL, CUS_AREACODE, CUS_PHONE FROM CUSTOMER_2; (including duplicated rows!) 9/9/2009 4 UNION ALL (contd) UNION ALL (contd) UNION ALL query results: 7-7 INTERSECT INTERSECT 7-8 9/9/2009 5 MINUS MINUS 7-9 SQL Functions...
View Full Document

Page1 / 14

Week 9 - 9/9/2009 1 Advanced SQL Advanced SQL Using and...

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

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