1 / 15

SQL = Sequel = Structured Query Language The Standard Language for Relational Databases

SQL = Sequel = Structured Query Language The Standard Language for Relational Databases. SQL: DDL, DML, DCL. SQL:. I) Go to SQL and Relational Algebra II) Go to Database Courseware -> SQL Query II.1) Construction II.2) Animating SQL Query with Procedural Code II.3) Advanced

Download Presentation

SQL = Sequel = Structured Query Language The Standard Language for Relational Databases

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. SQL = Sequel = Structured Query Language The Standard Language for Relational Databases

  2. SQL: DDL, DML, DCL

  3. SQL: I) Go to SQL and Relational Algebra II) Go to Database Courseware -> SQL Query II.1) Construction II.2) Animating SQL Query with Procedural Code II.3) Advanced -> Animating Complex SQL with Join with Minus II.4) SQL Visual Basic -> Join with 1 Table

  4. Unary Relationship in SQL(Join with 1 Table) EMP e EMP m Select e.ename, m.ename From emp e, emp m Where e.mgr = m.empno List name of employees and their managers

  5. Select e.ename, m.ename From emp e, emp m Where e.mgr = m.empno List name of employees and their managers EMP e EMP m INPUT INPUT output

  6. Outer Join • Take union of rows in two tables even when they are not union compatible. • For example (CAP database), we want the agent name listed together with their orders they placed. However, if the agent has no orders, we also want the agent listed.

  7. Outer join in Oracle • Insert agent john in agent table. • List agents and their corresponding orders. ANAME DOLLARS ------------- ---------- Brown 1104 Smith 460 Smith 500 John

  8. SQL syntax and processing SQL syntax: How SQL is processed: SELECT identify columns FROM identify tables WHERE rows meeting conditions GROUP BY organizes rows into groups ORDER BY sorts rows HAVING further subsets the groups

  9. Insert • One insert command can: 1) Insert one row or 2) Insert millions of rows; . Also, may write the insert commands in a batch file.

  10. Insert • One insert command can: 1) Insert one row or 2) Insert millions of rows; . Also, may write the insert commands in a batch file.

  11. Update • Update products set price = price * 1.05; • Update products set price = price * 1.10 where pid in (select pid from orders where aid in (select aid from agents where aname = ‘Smith’));

  12. Integrity constraints (DDL) • Created with create table or alter table command • Removed with alter table or drop table command. • On delete ….

  13. Creating Table with FK (DDL) • When creating a table Employee that has a FK did referencing Department, one must make sure the Department table has already been created first.

  14. Removing Table with FK (DDL) • When removing the tables, the order must be the opposite order in which they were created. First remove table Employee that has a FK did referencing Department, then remove table Department.

  15. Grant/Revoke (DCL) • Create user corporate_data; • Create user john mary and joe • Create tables accounts and transactions under the user corporate data • Grant select to everyone on accounts • Grant insert on transactions to mary • Grant select on transactions to joe, jone • Revoke joe’s right to select the accounts

More Related