# Displaying Data from Multiple Tables. Chapter 4

Save this PDF as:

Size: px
Start display at page:

## Transcription

1 Displaying Data from Multiple Tables Chapter 4 1

2 Objectives After completing this lesson, you should be able to do the following: Write SELECT statements to access data from more than one table using equality and nonequality joins View data that generally does not meet a join condition by using outer joins Join a table to itself Lesson Aim This lesson covers how to obtain data from more than one table, using the different methods available. 2

3 Cartesian Product A Cartesian product is formed when: A join condition is omitted A join condition is invalid All rows in the first table are joined to all rows in the second table To avoid a Cartesian product, always include a valid join condition in a WHERE clause. 3

4 Generating a Cartesian Product SELECT ename, dname FROM emp, dept; ENAME BLAKE SMITH ALLEN DNAME ACCOUNTING ACCOUNTING ACCOUNTING 56 Rows Selected 4

5 What Is a Join? Use a join to query data from more than one table. Old Syntax Write the join condition in the WHERE clause. SELECT FROM WHERE tablel.column, table2. column2 table1, table2 tablel. columnl = table2. column2; ANSI Syntax Write the join condition in the ON clause. SELECT tablel.column, table2. column2 FROM table1 INNER JOIN table2 ON tablel. columnl = table2. column2; Prefix the column name with the table name when the same column name appears in more than one table. Defining Joins When data from more than one table in the database is required, a join condition is used. Rows in one table can be joined to rows in another table according to common values existing in corresponding columns, that is, usually primary and foreign key columns. TO display data from two or more related tables, write a simple join condition in the WHERE clause, in the syntax: Table1.column1 denotes the table and column from which data is retrieved Table1. column1 = table2. column2 is the condition that joins (or relates) the tables together. 5

6 Types of Joins Equijoin Non-equijoin Outer join Self join 6

7 Types of Joins There are two main types of join conditions: Equijoins Non-equijoins Additional join methods include the following Outerjoins Selfjoins Set Operators Note: Set operators are not covered in this course. They are covered in another SQL course. 7

8 What Is an Equijoin? Equijoins To determine the name of an employee s department, you compare the value in the DEPTNO column in the EMP table with the DEPTNO values in the DEPT table. The relationship between the EMP and DEPT table is an equijoin - that is, values in the DEPTNO column on both tables must be equal. Frequently, this type of join involves primary and foreign key complements. Note: Equijoins are also called simple joins or innerjoins. Obtaining Data from Multiple Tables SELECT e.empno, e.deptno, d.loc FROM emp e, dept d WHERE e.deptno = d.deptno; Data from Multiple Tables Sometimes you need to use data from more than one table. In the slide example, the report displays data from two separate tables. EMPNO exists in the EMP table DEPTNO exists in both the EMP and DEPT the Tables. LOC exists in the DEPT table. To prodııce the report. you need to link EMP and DEPT tables and access data from both of them. 8

9 ANSI Syntax SELECT e.empno, e.deptno, d.loc FROM emp e inner join dept d on e.deptno = d.deptno; 9

10 Retrieving Records with Equijoins SELECT EMP.EMPNO, EMP.ENAME, EMP.DEPTNO, DEPT.DEPTNO, DEPT.LOC FROM EMP, DEPT WHERE EMP.DEPTNO = DEPT.DEPTNO EMPNO ENAME DEPTNO DEPTNO LOC 14 rows selected BLAKE CHICAGO 7369 SMITH DALLAS 7499 ALLEN CHICAGO Retrieving Records with Equijoins in the slide examaple. The SELECT clause specifies the column names to retrieve: - employee name, employee number, and department number, which are columns in the emp table - department number, department name, and location, which are columns in the DEPT table. The FROM clause specifies the two tables that the database must access: EMP table DEPT table The WHERE clause specifies how the tables are to be joined: EMP.DEPTNO=DEPT.DEPTNO 10

11 Oualifying Ambiguous Column Names Use table prefixes to qualify column names that are in multiple tables. Improve performance by using table prefixes. Distinguish columns that have identical names but reside in different tables by using column aliases. Qualifying Ambiguous Column Names You need to gualify the names of the columns in the WHERE clause ""itli the table names to avoid ambiguity without the table prefixes. the DEPTNO column could be from either the DEPT table or the EMP table. It is necessary to add the table prefix to execute your query. If there are no common column names between the two tables, there is no need to qualify the columns. Howevwr, you will gain improved performance by using the table prefix because you tell the Oracle Server exactly where to find the columns. 11

12 EQUIJOIN SELECT emp.empno, emp.ename, emp.deptno, dept.deptno, dept.loc FROM emp, dept WHERE emp.deptno = Dept.deptno; EMPNO ENAME DEPTNO DEPTNO LOC 7698 BLAKE CHICAGO 7369 SMITH DALLAS 14 rows selected. 12

13 Using Table Aliases The following two scripts are equivalent. In the second one table aliases are used. SELECT e.ename, e.deptno, d.dname FROM emp e, dept d WHERE e.deptno = d.deptno ; ENAME DEPTNO DNAME BLAKE SMITH 14 rows selected. 13

14 Additional Search Conditions Using the AND Operator Additional Search Conditions In addition to the join, you may have criteria for your WHERE clause. For example, to display King's employee number, name, department number, and departments localion, you need an additional condition in the WHERE clause. SELECT EMP.EMPNO, EMP.ENAME, EMP.DEPTNO, DEPT.DEPTNO, DEPT.LOC FROM EMP, DEPT WHERE EMP.DEPTNO = DEPT.DEPTNO AND INITCAP(ename) = 'King' ; EMPNO ENAME DEPTNO DEPTNO LOC 7839 KING NEW YORK 14

15 ANSI Ssyntax ORACLE da Inner Join i yapan FROM emp e, dept d WHERE e.deptno = d.deptno yerine FROM emp e INNER JOIN dept d inner Join koşulu yazıldıktan sonra iki tablo arasında bağlantıyı kuran ON e.deptno = d.deptno koşulu yazılır. Eğer, ayrıca satırlardan yeni süzme yapılacaksa WHERE ile istenen koşul konulabilir: WHERE INITCAP(ename) = 'King' ; Biçimindeki koşul yazılabilir. Örnek SELECT e.empno, e.ename, e.deptno, d.deptno, d.loc FROM emp e INNER JOIN dept d ON e.deptno = d.deptno WHERE INITCAP(ename) = 'King' ; EMPNO ENAME DEPTNO DEPTNO LOC 7839 KING NEW YORK 15

16 Non-Equijoins The relationship between the EMP table and the SALGRADE table is a non-equijoin, meaning that no column in the EMP table corresponds directly to a column in the SALGRADE table. The relationship between the two tables is that the SAL column in the EMP table is between the LOSAL and HISAL column of the SALGRADE table. The relationship is obtained using an operator other than equal (=). SELECT * FROM emp ; EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO 7698 BLAKE MANAGER /05/ rows selected. SELECT * FROM salgrade ; GRADE LOSAL HISAL 5 rows selected

17 Retreive records where Salary in the EMP table is between low salary and high salary in the SALGRADE table. SELECT e.ename, e.sal, s.grade FROM EMP e, SALGRADE s WHERE e.sal BETWEEN s.losal AND s.hisal ; ENAME SAL GRADE SMITH JAMES rows selected. 17

18 ANSI Syntax SELECT e.ename, e.sal, s.grade FROM EMP e INNER JOIN SALGRADE s ON e.sal BETWEEN s.losal AND s.hisal ; ENAME SAL GRADE SMITH JAMES rows selected. 18

19 Joining More Than Two Tables SELECT e.ename, e.deptno, d.dname, s.grade FROM emp e, dept d, salgrade s WHERE e.deptno = d.deptno AND e.sal BETWEEN s.losal AND hisal; ENAME DEPTNO DNAME GRADE KING 10 ACCOUNTING 5 CLARK 10 ACCOUNTING 4 MILLER 10 ACCOUNTING 2 FORD 4 SCOTT 4 JONES 4 ADAMS 1 SMITH 1 BLAKE 4 ALLEN 3 TURNER 3 MARTIN 2 WARD 2 JAMES 1 14 rows selected. 19

20 ANSI Syntax SELECT e.ename, e.deptno, d.dname, s.grade FROM salgrade s, emp e INNER JOIN dept d ON e.deptno = d.deptno WHERE e.sal BETWEEN s.losal AND s.hisal; ENAME DEPTNO DNAME GRADE KING 10 ACCOUNTING 5 CLARK 10 ACCOUNTING 4 MILLER 10 ACCOUNTING 2 14 rows selected. 20

21 Retrieving Records with Non-Equijoins SELECT e.ename, e.sal, s.grade FROM EMP e, SALGRADE s WHERE e.sal +e.comm > s.hisal ENAME SAL GRADE TURNER WARD ALLEN MARTIN TURNER WARD ALLEN MARTIN MARTIN rows selected. Non-Equijoins (continued) The slide example creates a non-equijoin to evaluate an employee's salary grade. The salary must be between any pair of the low and high salary ranges. It is important to note that all employees appear exactly once when this query is executed. No employee is repeated in the list. There are two reasons for this: None of the rows in the salary grade table contain grades that overlap. That is, the salary value for an employee can only lie between the low salary and high salary values of one of the rows in the salary grade table. All of the employees' salaries lie within the limits provided by the salary grade table. That is, no employee earns less than the lowest value contained in the LOSAL column or more than the highest value contained in the HISAL column. Note: Other operators such as <= and >= could be used, but BETWEEN is the simplest. Remember to specify the low value first and the high value last when using BETWEEN. Table aliases have been specified for performance reasons, not because of possible ambiguity. 21

22 ANSI Syntax (Non Equijoin) SELECT e.ename, e.sal, s.grade FROM EMP e INNER JOIN SALGRADE s ON e.sal +e.comm > s.hisal ; ENAME SAL GRADE ALLEN WARD MARTIN TURNER ALLEN WARD MARTIN TURNER MARTIN rows selected. 22

23 Outer joins When two tables are joined with an inner join, data will only be returned if matching data exists in both tables. An outer join is like saying "and also include the rows from one table if there are no matching rows in the other one." With an outer join the columns from the table where data is "missing" are returned as NULL values. Outer joins come in two basic flavours, called Left and Right. Left outer joins mean that the data must be contained in the table defined to the left side of the equivalence, but not necessarily the right hand side. Right outer joins, of course, work the other way around. To illustrate this, cut and paste the code below into a Query Analyser window and try running it. I have used the newer ANSI syntax here, and the older equivalents are included but commented out using the "--" comment notation. Comment them back in if you want to try them. 23

24 Outer Joins Returning Records with No Direct Match with Outer Joins If a row does not satisfy a join condition, the row will not appear in the query result. For example, in the equijoin condition of EMP and DEPT tables, department OPERATIONS does not appear because no one works in that department. SELECT e.ename, e.deptno, d.dname FROM emp e, dept d WHERE e.deptno = d.deptno; ENAME DEPTNO DNAME BLAKE SMITH ALLEN WARD JONES MARTIN CLARK 10 ACCOUNTING SCOTT KING 10 ACCOUNTING TURNER ADAMS JAMES FORD MILLER 10 ACCOUNTING 14 rows selected. No employee in the OPERATIONS department 24

25 Outer Joins Returning Records with No Direct Match with Outer Joins If a row does not satisfy a join condition, the row will not appear in the query result. For example, in the equijoin condition of EMP and DEPT tables, department OPERATIONS does not appear because no one works in that department. Outer Joins (Old usage) You use an outer join to also see rows that do not usually meet the join condition. Outer join operator is the plus sign (+). SELECT tablel.column, table2. column FROM tablel, table2 WHERE tablel.column(+) = table2.column; SELECT tablel.column, table2.column FROM tablel, table2 WHERE tablel.column. = table2. column {+) ; Returning Records with No Direct Match with Outer Joins The missing row(s) can be returned if an outerjoin operator is used in the join condition. The operator is a plus sign enclosed in parenthesis (+), and it is placed on the "side" of the equality that the join rhctt a defıcient in mfürmcınun. This operator has the effect of creating one or more mil l rows, to which one or more rows from the nondeficient table can be joined in the syntax. In the condition that joins (or relates) the lables together, is the outer join symbol, which can be placed on either side of the WHERE clause condition, but not on both sides (Place the outer join symbol following the name of the column in the table without the matching rows.) 25

26 Old Usage SELECT e.ename, e.deptno, d.dname FROM emp e, dept d WHERE e.deptno(+) = d.deptno; ENAME DEPTNO DNAME SMITH ALLEN WARD JONES MARTIN BLAKE CLARK SCOTT KING TURNER ADAMS JAMES FORD MILLER 10 ACCOUNTING 10 ACCOUNTING 10 ACCOUNTING OPERATIONS 15 rows selected. 26

27 ANSI Right Outer Join Syntax SELECT e.ename, e.deptno, d.dname FROM emp e RIGHT OUTER JOIN dept d ON e.deptno = d.deptno; ENAME DEPTNO DNAME SMITH ALLEN WARD JONES MARTIN BLAKE CLARK SCOTT KING TURNER ADAMS JAMES FORD MILLER 10 ACCOUNTING 10 ACCOUNTING 10 ACCOUNTING OPERATIONS 15 rows selected. 27

28 ANSI Left Outer Join Syntax SELECT e.ename, e.deptno, d.dname FROM emp e RIGHT OUTER JOIN dept d ON e.deptno = d.deptno; ENAME DEPTNO DNAME SMITH ALLEN WARD JONES MARTIN BLAKE CLARK SCOTT KING TURNER ADAMS JAMES FORD MILLER 10 ACCOUNTING 10 ACCOUNTING 10 ACCOUNTING 14 rows selected. 28

29 Old usage SELECT e.ename, e.deptno, d.dname FROM emp e, dept d WHERE e.deptno = d.deptno(+); ENAME DEPTNO DNAME SMITH ALLEN WARD JONES MARTIN BLAKE CLARK SCOTT KING TURNER ADAMS JAMES FORD MILLER 10 ACCOUNTING 10 ACCOUNTING 10 ACCOUNTING 14 rows selected. 29

30 OUTER JOIN Previously, we had looked at left join, or inner join, where we select rows common to the participating tables to a join. What about the cases where we are interested in selecting elements in a table regardless of whether they are present in the second table? We will now need to use the SQL OUTER JOIN command. The syntax for performing an outer join in SQL is database-dependent. For example, in Oracle, we will place an "(+)" in the WHERE clause on the other side of the table for which we want to include all the rows. Let's assume that we have the following two tables, Table Store_Information store_name Sales Date Los Angeles \$1500 Jan San Diego \$250 Jan Los Angeles \$300 Jan Boston \$700 Jan Table Geography region_name East East West West store_name Boston New York Los Angeles San Diego and we want to find out the sales amount for all of the stores. If we do a regular join, we will not be able to get what we want because we will have missed "New York," since it does not appear in the Store_Information table. Therefore, we need to perform an outer join on the two tables above: 30

31 OUTER JOIN SELECT A1.store_name, SUM(A2.Sales) SALES FROM Geography A1, Store_Information A2 WHERE A1.store_name = A2.store_name (+) GROUP BY A1.store_name Note that in this case, we are using the Oracle syntax for outer join. Result: store_name SALES Boston \$700 New York Los Angeles \$1800 San Diego \$250 Note: NULL is returned when there is no match on the second table. In this case, "New York" does not appear in the table Store_Information, thus its corresponding "SALES" column is NULL. 31

32 ORDER BY usage in OUTER JOIN ALLEN WARD SELECT e.ename, d.deptno, d.dname FROM emp e, dept d WHERE e.deptno(+) = d.deptno ORDER BY e.deptno; ENAME DEPTNO DNAME 15 rows selected. 40 OPERATIONS 32

33 ANSI Syntax for OUTER JOIN SELECT e.ename, d.deptno, d.dname FROM emp e RIGHT OUTER JOIN dept d ON e.deptno = d.deptno ORDER BY e.deptno; ENAME DEPTNO DNAME CLARK MILLER KING JONES SMITH SCOTT FORD ADAMS WARD TURNER ALLEN JAMES MARTIN BLAKE 10 ACCOUNTING 10 ACCOUNTING 10 ACCOUNTING 40 OPERATIONS 15 rows selected. 33

34 Using Outer Joins SELECT e.ename, d.deptno, d.dname FROM emp e, dept d WHERE e.deptno(+) = d.deptno ORDER BY e.deptno; ENAME DEPTNO DNAME MILLER 10 ACCOUNTING KING 10 ACCOUNTING CLARK 10 ACCOUNTING SMITH FORD ADAMS SCOTT JONES TURNER JAMES ALLEN MARTIN BLAKE WARD 40 OPERATIONS 15 rows selected. 34

35 Joining a Table to Itself SQL JOIN Now we want to look at joins. To do joins correctly in SQL requires many of the elements we have introduced so far. Let's assume that we have the following two tables, Table Store_Information store_name Sales Date Los Angeles \$1500 Jan San Diego \$250 Jan Los Angeles \$300 Jan Boston \$700 Jan Table Geography region_name East East West West store_name Boston New York Los Angeles San Diego and we want to find out sales by region. We see that table Geography includes information on regions and stores, and table Store_Information contains sales information for each store. To get the sales information by region, we have to combine the information from the two tables. Examining the two tables, we find that they are linked via the common field, "store_name". We will first present the SQL statement and explain the use of each segment later: 35

36 Joining a Table to Itself SELECT A1.region_name REGION, SUM(A2.Sales) SALES FROM Geography A1, Store_Information A2 WHERE A1.store_name = A2.store_name GROUP BY A1.region_name Result: REGION SALES East \$700 West \$2050 The first two lines tell SQL to select two fields, the first one is the field "region_name" from table Geography (aliased as REGION), and the second one is the sum of the field "Sales" from table Store_Information (aliased as SALES). Notice how the table aliases are used here: Geography is aliased as A1, and Store_Information is aliased as A2. Without the aliasing, the first line would become SELECT Geography.region_name REGION, SUM(Store_Information.Sales) SALES which is much more cumbersome. In essence, table aliases make the entire SQL statement easier to understand, especially when multiple tables are included. Next, we turn our attention to line 3, the WHERE statement. This is where the condition of the join is specified. In this case, we want to make sure that the content in "store_name" in table Geography matches that in table Store_Information, and the way to do it is to set them equal. This WHERE statement is essential in making sure you get the correct output. Without the correct WHERE statement, a Cartesian Join will result. Cartesian joins will result in the query returning every possible combination of the two (or whatever the number of tables in the FROM statement) tables. In this case, a Cartesian join would result in a total of 4 x 4 = 16 rows being returned. 36

37 Self Joins MGR in the WORKER table is equal to EMPNO in the MANAGER table. SELECT WORKER.ename, WORKER.empno, MANAGER.ename, MANAGER.empno FROM emp WORKER, emp MANAGER WHERE WORKER.mgr = MANAGER.empno ; ENAME EMPNO ENAME EMPNO JAMES 7900 BLAKE 7698 TURNER 7844 BLAKE 7698 MARTIN 7654 BLAKE 7698 WARD 7521 BLAKE 7698 ALLEN 7499 BLAKE 7698 FORD 7902 JONES 7566 SCOTT 7788 JONES 7566 MILLER 7934 CLARK 7782 ADAMS 7876 SCOTT 7788 CLARK 7782 KING 7839 JONES 7566 KING 7839 BLAKE 7698 KING 7839 SMITH 7369 FORD rows selected. 37

38 Self Joins Use two alias for emp: SELECT e.ename, e.empno, m.ename, m.empno FROM emp e, emp m WHERE e.mgr = m.empno ; ENAME EMPNO ENAME EMPNO JAMES 7900 BLAKE 7698 TURNER 7844 BLAKE 7698 MARTIN 7654 BLAKE 7698 WARD 7521 BLAKE 7698 ALLEN 7499 BLAKE 7698 FORD 7902 JONES 7566 SCOTT 7788 JONES 7566 MILLER 7934 CLARK 7782 ADAMS 7876 SCOTT 7788 CLARK 7782 KING 7839 JONES 7566 KING 7839 BLAKE 7698 KING 7839 SMITH 7369 FORD rows selected. 38

39 ANSI Syntax for SELF JOIN SELECT e.ename, e.empno, m.ename, m.empno FROM emp e INNER JOIN emp m ON e.mgr = m.empno ; ENAME EMPNO ENAME EMPNO SMITH 7369 FORD 7902 ALLEN 7499 BLAKE 7698 WARD 7521 BLAKE 7698 JONES 7566 KING 7839 MARTIN 7654 BLAKE 7698 BLAKE 7698 KING 7839 CLARK 7782 KING 7839 SCOTT 7788 JONES 7566 TURNER 7844 BLAKE 7698 ADAMS 7876 SCOTT 7788 JAMES 7900 BLAKE 7698 FORD 7902 JONES 7566 MILLER 7934 CLARK rows selected. 39

40 SELF JOINS SELECT worker.ename 'works for ' manager.ename FROM emp worker, emp manager WHERE worker.mgr = manager.empno; WORKER.ENAME 'WORKSFOR' MANAGER.ENAME SMITHworks for FORD ALLENworks for BLAKE WARDworks for BLAKE JONESworks for KING MARTINworks for BLAKE BLAKEworks for KING CLARKworks for KING SCOTTworks for JONES TURNERworks for BLAKE ADAMSworks for SCOTT JAMESworks for BLAKE FORDworks for JONES MILLERworks for CLARK 13 rows selected. Joining a Table to Itself (continued) The slide example joins the EMP table to itself. To simulate two tables in the FROM clause, there are two aliases, namely WORKER and MANAGER, for the same table EMP. In this example, the WHERE clause contains the join that means ''where a worker's manager number matches the employee number for the manager. 40

41 ANSI syntax for SELF JOINS SELECT worker.ename 'works for ' manager.ename FROM emp worker INNER JOIN emp manager ON worker.mgr = manager.empno; WORKER.ENAME 'WORKSFOR' MANAGER.ENAME SMITHworks for FORD ALLENworks for BLAKE WARDworks for BLAKE JONESworks for KING MARTINworks for BLAKE BLAKEworks for KING CLARKworks for KING SCOTTworks for JONES TURNERworks for BLAKE ADAMSworks for SCOTT JAMESworks for BLAKE FORDworks for JONES MILLERworks for CLARK 13 rows selected. 41

42 Self Joins SELECT e.ename, e.empno, m.ename, m.empno FROM emp e, emp m WHERE e.mgr = m.empno; ENAME EMPNO ENAME EMPNO JAMES 7900 BLAKE 7698 TURNER 7844 BLAKE rows selected. Joining a Table to Itself Sometimes you need to join a table to itself. To find the name of each employee's manager, you need to join the EMP table to itself, or perform a self join. For example, to find the name of Blake's manager, you need to: Find Blake in the EMP table by looking at the ENAME column. Find the manager number for Blake by looking at the MGR column. Blake's manager number is Find the name of the manager with EMPNO 7839 by looking at the ENAME column. King's employee number is 7839, so King is Blake's manager. In this process, you look in the table twice. The first time you look in the table to find Blake in the ENAME column and MGR value of The second time you look in the EMPNO column to find 7839 and the ENAME column to find King ANSI Syntax for Self Join SELECT e.ename, e.empno, m.ename, m.empno FROM emp e INNER JOIN emp m ON e.mgr = m.empno; 42

43 Summary Summary SELECT tablel. Column, table2. column FROM tablel, table2 WHERE tablel. columnl = table2. column2; Equijoin Non-equijoin Outer join Self join There are multiple ways to join tables. The common thread, though, is that you want to link them through a condition in the WHERE clause. The method you choose will be based on the required result and the data structures that you are using. 43

44 Exercices Solution 1 SELECT e.ename, e.deptno, d.dname FROM emp e, dept d WHERE e.deptno = d.deptno ; Solution 2 SELECT e.job, d.loc FROM emp e, dept d WHERE e.deptno = d.deptno AND e.deptno = 30; Solution 3 SELECT e.ename, d.dname, d.loc FROM emp e, dept d WHERE comm IS NOT NULL AND e.deptno = d.deptno ; Solution 4 SELECT e.ename, d.dname, d.loc FROM emp e, dept d WHERE comm IS NOT NULL AND e.deptno = d.deptno ; Solution 5 SELECT e.ename, e.job, e.deptno, d.dname FROM emp e, dept d WHERE e.deptno = d.deptno AND d.loc = 'DALLAS' ; Solution 6 SELECT e.ename "İşçi", e.empno "İşçi No", m.ename "Manager", m.empno "Mgr No" FROM emp e, emp m WHERE e.mgr = m.empno ; Solution 7 SELECT e.ename "İşçi", e.empno "İşçi No", m.ename "Manager", m.empno "Mgr No" FROM emp e, emp m WHERE e.mgr = m.empno(+) ; 44

45 Solution 8a SELECT e.deptno "Bölüm", e.ename "İşçi", b.ename FROM emp e, emp b WHERE e.deptno = b.deptno ORDER BY e.empno ; Solution 8b SELECT e.deptno "Bölüm", e.ename "İşçi", b.ename FROM emp e, emp b WHERE e.deptno = b.deptno AND e.ename!= b.ename ORDER BY e.empno ; Solution 8c SELECT e.deptno "Bölüm", e.ename "İşçi", b.ename FROM emp e, emp b WHERE e.deptno = b.deptno AND e.ename <> b.ename ORDER BY e.deptno ; Solution 9a DESC salgrade; Solution 9b SELECT e.ename "İşçi", e.job "İşi", d.dname "Bölümü", e.sal "Maaş", s.grade "Barem" FROM emp e, dept d, salgrade s WHERE e.deptno = d.deptno AND e.sal BETWEEN s.losal AND s.hisal ; Solution 10 SELECT e.ename "İşçi", e.hiredate "İşe Giriş Tarihi", b.hiredate "Blake" FROM emp e, emp b WHERE e.hiredate > b.hiredate AND b.ename = 'BLAKE' ; Solution 11 SELECT e.ename "İşçi", e.hiredate "İşe Giriş Tarihi", m.ename "Manageri", m.hiredate "Managerin Giriş Tar" FROM emp e, emp m WHERE e.hiredate < m.hiredate AND e.mgr = m.empno ; 45

### Displaying Data from Multiple Tables

Displaying Data from Multiple Tables 1 Objectives After completing this lesson, you should be able to do the following: Write SELECT statements to access data from more than one table using eguality and

### Database implementation Introduction to SQL

IRU SEMESTER 2 January 2010 Semester 1 Session 1 Database implementation Introduction to SQL Objectives To be able to connect to the local ORACLE database To be able to describe the component parts of

### RDBMS Using Oracle. Lecture Week 7 Introduction to Oracle 9i SQL Last Lecture. kamran.munir@gmail.com. Joining Tables

RDBMS Using Oracle Lecture Week 7 Introduction to Oracle 9i SQL Last Lecture Joining Tables Multiple Table Queries Simple Joins Complex Joins Cartesian Joins Outer Joins Multi table Joins Other Multiple

### SQL: Update 2/11/2008. USC - CSCI585 - Spring Farnoush Banaei-Kashani

SQL: Update 1 Example Schema Dept (DeptNo, Name, Location) Emp (EmpNo, Name, Job, Sal, Comm, HireDate, Mgr, DeptNo) Dept DeptNo Name Location Number(2) Varchar2(14) Varchar2(13) Emp EmpNo Name Job Sal

### Subqueries Chapter 6

Subqueries Chapter 6 Objectives After completing this lesson, you should be able to do the follovving: Describe the types of problems that subqueries can solve Define subqueries List the types of subqueries

### Displaying Data from Multiple Tables

4 Displaying Data from Multiple Tables Copyright Oracle Corporation, 2001. All rights reserved. Schedule: Timing Topic 55 minutes Lecture 55 minutes Practice 110 minutes Total Objectives After completing

### Chapter 2. Restricting and Sorting Data

Chapter 2 Restricting and Sorting Data 1 Objectives After completing this lesson, you should be able to do the following: Limit the rows retrieved by a query Sort the rows retrieved by a query Lesson Aim

Table EMP 1. Insert a record with suitable data in the table emp, having emp as the Hiredate. SQL> insert into emp values (3008,18,'Xavier', 7782, sysdate, 3250, NULL, 20); 2. Write a statement to show

### Database CIS 340. lab#6. I.Arwa Najdi a_najdi1988@yahoo.com

Database CIS 340 lab#6 I.Arwa Najdi a_najdi1988@yahoo.com Outlines Obtaining Data from Multiple Tables (Join) Equijoins= inner join natural join Creating Joins with the USING Clause Creating Joins with

### SQL DML. Session 6 (CSCI-585) Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1

SQL DML Session 6 (CSCI-585) Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1 Dept (DeptNo, Name, Location) Example Schema Emp (EmpNo, Name, Job, Sal, Comm, HireDate, Mgr, DeptNo) Dept

### Limiting Rows Using a Selection

Limiting Rows Using a Selection EMP EMPNO ENAME JOB... DEPTNO 7839 KING PRESIDENT 10 7698 BLAKE MANAGER 30 7782 CLARK MANAGER 10 7566 JONES MANAGER 20... EMP EMPNO ENAME JOB retrieve all employees in department

### Indexing and Query Execution

Introduction to Databases Fall-Winter 2009/10 Exercises Michail Kazimianec Werner Nutt Damiano Somenzi Indexing and Query Execution We consider in these exercises queries posed over the employee database

### Retrieval: Multiple Tables and Aggregation

4487CH08.qxd 11/24/04 10:15 AM Page 191 CHAPTER 8 Retrieval: Multiple Tables and Aggregation This chapter resumes the discussion of the retrieval possibilities of the SQL language. It is a logical continuation

### Where? Originating Table Employees Departments

JOINS: To determine an employee s department name, you compare the value in the DEPARTMENT_ID column in the EMPLOYEES table with the DEPARTMENT_ID values in the DEPARTMENTS table. The relationship between

Displaying Data from Multiple Tables Objectives After completing this lesson, you should be able to do the following: Write SELECT statements to access data from more than one table using equijoins and

### FROM tablename [,tablename [,tablename. A query to combine the EMP and DEPT tables would look like this:

Combining Tables Cartesian Product Multiple tables in the FROM clause There may be instances when a query requires information from two or more tables to be collated in some way, for example, to find out

### Introduction to the Relational Model and SQL

Introduction to the Relational Model and SQL 69 After completing this chapter, you should be able to: explain basic notions of the relational model: table/relation, row/tuple, column/attribute, column

### Introduction to the Relational Model and SQL

Introduction to the Relational Model and SQL 61 After completing this chapter, you should be able to: explain basic notions of the relational model: table/relation, row/tuple, column/attribute, column

### Update the salary of each employee by 10% increments that are not eligible for commission. update emp set sal=sal+(sal*10/100) where comm is null;

Display grade and employees name for the dept no 10 or 30 but grade is not 4, while joined the company before 31-dec-82. select empno,ename,sal,deptno,hiredate,grade from emp e,salgrade s where e.sal>=s.losal

### Chapter 1. Writing Basic. SQL Statements

Chapter 1 Writing Basic SQL Statements 1 Objectives After completing this lesson, you should be able to do the following: List the capabilities of SQL SELECT statements Execute a basic SELECT statement

### Including Constraints Schedule: Timing Topic

10 Including Constraints Schedule: Timing Topic 45 minutes Lecture 25 minutes Practice 70 minutes Total Objectives After completing this lesson, you should be able to do the following: Describe constraints

### Aggregating Data Using Group Functions

Aggregating Data Using Group Functions Objectives Capter 5 After completing this lesson, you should be able to do the following: Identify the available group functions Describe the use of group functions

### Practical Workbook Database Management Systems

Practical Workbook Database Management Systems Name : Year : Batch : Roll No : Department: Second Edition Reviewed in 2011 Department of Computer & Information Systems Engineering NED University of Engineering

### List of Practical Exercises (ORACLE)

ASSIGNMENT Batch : 2010-12 Session : 2011-12 Programme: MBA Semester : III/IV Course Code : MS-251 Course Title : DBMS Lab List of Practical Exercises (ORACLE) (Set 1) Note: Consider the EMP and DEPT tables

### GET DATA FROM MULTIPLE TABLES QUESTIONS

GET DATA FROM MULTIPLE TABLES QUESTIONS http://www.tutorialspoint.com/sql_certificate/get_data_from_multiple_tables_questions.htm Copyright tutorialspoint.com 1.Which of the following is not related to

### Chapter 9 Joining Data from Multiple Tables. Oracle 10g: SQL

Chapter 9 Joining Data from Multiple Tables Oracle 10g: SQL Objectives Identify a Cartesian join Create an equality join using the WHERE clause Create an equality join using the JOIN keyword Create a non-equality

### Practical Workbook Database Management Systems

Practical Workbook Database Management Systems Name : Year : Batch : Roll No : Department: Fourth Edition Reviewed in 2015 Department of Computer & Information Systems Engineering NED University of Engineering

Displaying Data from Multiple Tables Copyright 2004, Oracle. All rights reserved. Objectives After completing this lesson, you should be able to do the following: Write SELECT statements to access data

Displaying Data from Multiple Tables Objectives After completing this lesson, you should be able to do the following: Write SELECT statements to access data from more than one table using equijoins and

### THE SQL SELECT STATEMENT QUESTIONS

THE SQL SELECT STATEMENT QUESTIONS http://www.tutorialspoint.com/sql_certificate/the_sql_select_statement_questions.htm Copyright tutorialspoint.com 1. Identify the capabilities of SELECT statement. A.

### DEPARTMENT OF COMPUTER SCIENCE

DEPARTMENT OF COMPUTER SCIENCE Topic :SQL EMP Empno Ename Job Mgr Hiredate Sal Comm. Deptno 7839 King President 17-nov-81 5000 10 7698 Blake Manager 7839 01-may-81 2850 30 7782 Clark Manager 7839 09-jun-81

### Producing Readable Output with SQL*Plus

Producing Readable Output with SQL*Plus Chapter 8 Objectives After completing this lesson, you should be able to do the following: Produce queries that require an input variable Customize the SQL*Plus

### Lab # 5. Retreiving Data from Multiple Tables. Eng. Alaa O Shama

The Islamic University of Gaza Faculty of Engineering Department of Computer Engineering ECOM 4113: Database Lab Lab # 5 Retreiving Data from Multiple Tables Eng. Alaa O Shama November, 2015 Objectives:

### Database Design. Marta Jakubowska-Sobczak IT/ADC based on slides prepared by Paula Figueiredo, IT/DB

Marta Jakubowska-Sobczak IT/ADC based on slides prepared by Paula Figueiredo, IT/DB Outline Database concepts Conceptual Design Logical Design Communicating with the RDBMS 2 Some concepts Database: an

More advanced Selection queries Ordering results ORDER BY In a table, the order of the records (rows) cannot be guaranteed in fact as records are added (to the bottom of the table) and deleted (from the

More advanced Selection queries Ordering results ORDER BY In a table, the order of the records (rows) cannot be guaranteed in fact as records are added (to the bottom of the table) and deleted (from the

### Data vs. Information. Data vs. Information. Where We Are. FIT1004 Database Topic 1: Introduction

FIT1004 Database Topic 1: Introduction Learning Objectives: Data, Database, DBMS Understand the motivation for the Database Approach The Database System Environment Objectives of Database Technology DBMS

### Part 2: Introduction to the Relational Model and SQL

2. Introduction to the Relational Model and SQL 2-1 Part 2: Introduction to the Relational Model and SQL References: Elmasri/Navathe: Fundamentals of Database Systems, 3rd Edition, 1999. Section 7.1, Relational

### Oracle/SQL Tutorial 1

Oracle/SQL Tutorial 1 Michael Gertz Database and Information Systems Group Department of Computer Science University of California, Davis gertz@cs.ucdavis.edu http://www.db.cs.ucdavis.edu This Oracle/SQL

### IRU (Information Retrieval and Use) Module Handbook

IRU (Information Retrieval and Use) Module Handbook 2009-2010 Contents Book list Module Specification Schedule Connecting to SQL Changing your password Creating the EMP and DEPT tables Exercises Book List

### Data Models and Database Management Systems (DBMSs) Dr. Philip Cannata

Data Models and Database Management Systems (DBMSs) Dr. Philip Cannata 1 Data Models in the 1960s, 1970s, and 1980s Hierarchical Network (Graph) Relational Schema (Model) - first 1956 Vern Watts was IMS's

### Multiple-Column Subqueries Schedule: Timing Topic

7 Multiple-Column Subqueries Schedule: Timing Topic 20 minutes Lecture 20 minutes Practice 40 minutes Total Objectives After completing this lesson, you should be able to do the following: Write a multiple-column

### Assignment # 2. Database Systems. Due Date: Tuesday, 11 November 2008

Assignment # 2 Database Systems Due Date: Tuesday, 11 November 2008 Roll No Name Signature PART 1 THE SAMPLE TABLES EMP EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO 7369 SALMAN CLERK 7902 17 DEC 2000 8000

### 28. List the emps those who joined in 80 s. A) select * from emp where to_char(hiredate, yy ) like 8% ;

SQL-QUERIES 1. Display all the information of the EMP table? A) select * from emp; 2. Display unique Jobs from EMP table? A) select distinct job from emp; B) select unique job from emp; 3. List the emps

### SQL for Practical Records Using MySQL

SQL for Practical Records Using MySQL 01. Create the following relations DEPT and EMP. On the basis of the two tables write SQL commands and their outputs: Relation : DEPT Deptno Dname Loc 10 ACCOUNTING

### Example Schema DDL. create table dept( deptno number(2,0), dname varchar2(14), loc varchar2(13), constraint pk_dept primary key (deptno) );

Example Schema I often use the EMP and DEPT tables for test and demonstration purposes. Both these tables are owned by the SCOTT user, together with two less frequently used tables: BONUS and SALGRADE.

### SQL Introduction Chapter 7, sections 1 & 4. Introduction to SQL. Introduction to SQL. Introduction to SQL

SQL Introduction Chapter 7, sections 1 & 4 Objectives To understand Oracle s SQL client interface Understand the difference between commands to the interface and SQL language. To understand the Oracle

### QUETZALANDIA.COM WRITING BASIC SQL STATEMENTS -- CHAPTER 1

WRITING BASIC SQL STATEMENTS -- CHAPTER 1 SELECT statement retrieves information from the database by doing one of the following: (1) Selection to choose the rows in a table that you want returned by a

### Solutions Assignment 1

Solutions Assignment 1 A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 Display the contents of the DEPT, EMP and SALGRADE tables. [Check your results against the tables listed.] from Emp from dept from salgrade Display

Retrieving Data Using the SQL SELECT Statement Objectives After completing this lesson, you should be able to do the following: List the capabilities of SQL SELECT statements Execute a basic SELECT statement

### CHAPTER 12. SQL Joins. Exam Objectives

CHAPTER 12 SQL Joins Exam Objectives In this chapter you will learn to 051.6.1 Write SELECT Statements to Access Data from More Than One Table Using Equijoins and Nonequijoins 051.6.2 Join a Table to Itself

### Database Access from a Programming Language: Database Access from a Programming Language

Database Access from a Programming Language: Java s JDBC Werner Nutt Introduction to Databases Free University of Bozen-Bolzano 2 Database Access from a Programming Language Two Approaches 1. Embedding

### Database Access from a Programming Language:

Database Access from a Programming Language: Java s JDBC Werner Nutt Introduction to Databases Free University of Bozen-Bolzano 2 Database Access from a Programming Language Two Approaches 1. Embedding

### RESTRICTING AND SORTING DATA QUESTIONS

RESTRICTING AND SORTING DATA QUESTIONS http://www.tutorialspoint.com/sql_certificate/restricting_and_sorting_data_questions.htm Copyright tutorialspoint.com 1. Which of the following clause is used to

### CS275 Spring SQL Introduction PartB Chapter 7.2, section 4 & 6. SQL Functions Aggregate functions. Aggregate Functions: MAX & MIN

SQL Introduction PartB Chapter 7.2, section 4 & 6 Objectives: to learn The basic commands and functions of SQL How to use SQL to query a database for useful information How to display the data so that

### ว ตถ ประสงค 1. เพ อทบทวน Relational Data Model 2. เพ อให น กศ กษาได ทดลองค าส ง SQL Query Language เบ องต น Note. โดยใช MySQL

Database System LAB 2 ว ตถ ประสงค 1. เพ อทบทวน Relational Data Model 2. เพ อให น กศ กษาได ทดลองค าส ง SQL Query Language เบ องต น Note. โดยใช MySQL ว ตถ ประสงค 1 เพ อทบทวน Relational Data Model 1.1 จาก

### SQL Introduction Chapter 7, sections 4.4 & 6.4. SQL Functions Aggregate functions. Aggregate Functions: MAX & MIN. Aggregate Functions

SQL Introduction Chapter 7, sections 4.4 & 6.4 Objectives: to learn The basic commands and functions of SQL How to use SQL to query a database for useful information How to display the data so that it

12 SQL*Loader Case Studies The case studies in this chapter illustrate some of the features of SQL*Loader. These case studies start simply and progress in complexity. Note: The commands used in this chapter,

### Conversion Functions

Conversion Functions Conversion functions convert a value from one datatype to another. Generally, the form of the function names follows the convention datatype TO datatype. The first datatype is the

### Dr. Philip Cannata Data Management 2

B-Tree Indexing Dr. Philip Cannata Data Management 2 Dr. Philip Cannata Data Management 3 Dr. Philip Cannata Data Management 4 emp table DDL CREATE TABLE "SCOTT"."EMP" ( "EMPNO" NUMBER(4,0) NOT NULL ENABLE,

### Deep Dive into Oracle 12c Pattern Matching

Deep Dive into Oracle 12c Pattern Matching Oren Nakdimon oren.nakdimon@moovitapp.com +972-54-4393763 Who Am I? a chronology by Oracle years When What Where Oracle 6/7 1991-1997 Developer IAF Oracle 8 1997-1998

### 1. Which is the subset of SQL commands used to manipulate Oracle Database structures, including tables? Data Definition Language (DDL)

SQL 1. Which is the subset of SQL commands used to manipulate Oracle Database structures, including tables? Data Definition Language (DDL) 2. What operator performs pattern matching? LIKE operator 3. What

### Objectives. Oracle SQL and SQL*PLus. Database Objects. What is a Sequence?

Oracle SQL and SQL*PLus Lesson 12: Other Database Objects Objectives After completing this lesson, you should be able to do the following: Describe some database objects and their uses Create, maintain,

### Using SQL Queries to Insert, Update, Delete, and View Data: Joining Multiple Tables. Lesson C Objectives. Joining Multiple Tables

Using SQL Queries to Insert, Update, Delete, and View Data: Joining Multiple Tables Wednesay 9/24/2014 Abdou Illia MIS 4200 - Fall 2014 Lesson C Objectives After completing this lesson, you should be able

### Using TimesTen between your Application and Oracle. between your Application and Oracle. DOAG Conference 2011

DOAG Conference 2011 Using TimesTen between your Application and Oracle Jan Ott, Roland Stirnimann Senior Consultants Trivadis AG BASEL 1 BERN LAUSANNE ZÜRICH DÜSSELDORF FRANKFURT A.M. FREIBURG I.BR. HAMBURG

### SQL the natural language for analysis ORACLE WHITE PAPER JUNE 2015

SQL the natural language for analysis ORACLE WHITE PAPER JUNE 2015 Contents Overview 1 Introduction 1 Powerful Framework 1 Simplified Optimization 6 Continuous Evolution 8 Standards Based 9 Why Oracle

### D B M G Data Base and Data Mining Group of Politecnico di Torino

Politecnico di Torino Database Management System Oracle Hints Data Base and Data Mining Group of Politecnico di Torino Tania Cerquitelli Computer Engineering, 2014-2015, slides by Tania Cerquitelli and

### BASING A FORMS DATA BLOCK ON A JOIN

BASING A FORMS DATA BLOCK ON A JOIN INTRODUCTION Oracle9i Forms Developer offers several ways of defining the data for a block. Simple tables, database views, from clause queries, and stored server-side

### Duration Vendor Audience 5 Days Oracle End Users, Developers, Technical Consultants and Support Staff

D80198GC10 Oracle Database 12c SQL and Fundamentals Summary Duration Vendor Audience 5 Days Oracle End Users, Developers, Technical Consultants and Support Staff Level Professional Delivery Method Instructor-led

### Examine the structure of the EMPLOYEES table: EMPLOYEE_ID NUMBER Primary Key FIRST_NAME VARCHAR2(25) LAST_NAME VARCHAR2(25)

Examine the structure of the EMPLOYEES table: EMPLOYEE_ID NUMBER Primary Key FIRST_NAME VARCHAR2(25) LAST_NAME VARCHAR2(25) Which three statements inserts a row into the table? A. INSERT INTO employees

### SQL & PL/SQL Hands on Oracle 11g DB Enterprise Edition

SQL & PL/SQL Hands on Oracle 11g DB Enterprise Edition Writtent By: Abaid ur Rehman Project Manager +966506220025 ICM Software House Contents SQL(Structured Query Languages)... 4 DCL(Data Control Languages)...

### 5. Integrity Constraints

ECS-165A WQ 11 93 5. Integrity Constraints Contents Referential Integrity revisited Assertions Triggers ECS-165A WQ 11 94 Referential Integrity Ensures that a value that appears in one relation for a given

### DB2 Developers Guide to Optimum SQL Performance

DB2 Developers Guide to Optimum SQL Performance Réunion du Guide DB2 pour z/os France Lundi 18 mars 2013 Tour Euro Plaza, Paris-La Défense Tom Beavin Silicon Valley Lab Email: beavin@us.ibm.com 2012 IBM

### David L. Fuston, dfuston@vlamis.com Vlamis Software Solutions, Inc., www.vlamis.com

Data Warehouse and E-Business Intelligence ORACLE S SQL ANALYTIC FUNCTIONS IN 8i AND 9i David L. Fuston, dfuston@vlamis.com, www.vlamis.com INTRODUCTION The SQL language has traditionally provided little

### Appendix A Practices and Solutions

Appendix A Practices and Solutions Table of Contents Practices for Lesson I... 3 Practice I-1: Introduction... 4 Practice Solutions I-1: Introduction... 5 Practices for Lesson 1... 11 Practice 1-1: Retrieving

### Relational Algebra. Query Languages Review. Operators. Select (σ), Project (π), Union ( ), Difference (-), Join: Natural (*) and Theta ( )

Query Languages Review Relational Algebra SQL Set operators Union Intersection Difference Cartesian product Relational Algebra Operators Relational operators Selection Projection Join Division Douglas

### DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING DR.NAVALAR NEDUNCHEZHIAYN COLLEGE OF ENGINEERING, THOLUDUR-606303, CUDDALORE DIST.

CS2258-DATABASE MANAGEMENT SYSTEM LABORATORY LABORATORY MANUAL FOR IV SEMESTER B. E / CSE & IT (FOR PRIVATE CIRCULATION ONLY) ACADEMIC YEAR: 2013 2014 (EVEN) ANNA UNIVERSITY, CHENNAI DEPARTMENT OF COMPUTER

Restricting and Sorting Data Objectives After completing this lesson, you should be able to do the following: Limit the rows that are retrieved by a query Sort the rows that are retrieved by a query Use

### Relational Database: Additional Operations on Relations; SQL

Relational Database: Additional Operations on Relations; SQL Greg Plaxton Theory in Programming Practice, Fall 2005 Department of Computer Science University of Texas at Austin Overview The course packet

### Hidden Features You Probably Don t Know About And Are FREE. Graham Wood Oracle Corp

Hidden Features You Probably Don t Know About And Are FREE Graham Wood Oracle Corp Features You Probably Don t Know About And Are MOSTLY FREE 1977 Oracle Database 30 Years of Sustained Innovation Database

### 1 Structured Query Language: Again. 2 Joining Tables

1 Structured Query Language: Again So far we ve only seen the basic features of SQL. More often than not, you can get away with just using the basic SELECT, INSERT, UPDATE, or DELETE statements. Sometimes

### Database Query 1: SQL Basics

Database Query 1: SQL Basics CIS 3730 Designing and Managing Data J.G. Zheng Fall 2010 1 Overview Using Structured Query Language (SQL) to get the data you want from relational databases Learning basic

### Relational Database and SQL Prepared by Salvatore T. March, Jungpil Hahn and Jinsoo Park For Classroom Use Only

Relational Database and SQL Prepared by Salvatore T. March, Jungpil Hahn and Jinsoo Park For Classroom Use Only Introduction The database layer of an information system provides its requisite persistence

### Hours / 100 Marks Seat No.

17332 14115 3 Hours / 100 Seat No. Instructions (1) All Questions are Compulsory. (2) Illustrate your answers with neat sketches wherever necessary. (3) Figures to the right indicate full marks. (4) Mobile

### Unit 3. Retrieving Data from Multiple Tables

Unit 3. Retrieving Data from Multiple Tables What This Unit Is About How to retrieve columns from more than one table or view. What You Should Be Able to Do Retrieve data from more than one table or view.

### SQL> SELECT ename, job, sal Salary. 1.4.Will the SELECT statement execute successfully? True/False

BASES DE DATOS Ingeniería Técnica Informática Asignatura Obligatoria: 4.5 + 4.5 créditos (Segundo cuatrimestre) Curso académico 2000/2002 Relación de Ejercicios Prácticos TEMA 1. MANDATO SELECT BÁSICO

### SQL Tuning Proven Methodologies

SQL Tuning Proven Methodologies V.Hariharaputhran V.Hariharaputhran o Twelve years in Oracle Development / DBA / Big Data / Cloud Technologies o All India Oracle Users Group (AIOUG) Evangelist o Passion

### D61830GC30. MySQL for Developers. Summary. Introduction. Prerequisites. At Course completion After completing this course, students will be able to:

D61830GC30 for Developers Summary Duration Vendor Audience 5 Days Oracle Database Administrators, Developers, Web Administrators Level Technology Professional Oracle 5.6 Delivery Method Instructor-led

### Information Systems SQL. Nikolaj Popov

Information Systems SQL Nikolaj Popov Research Institute for Symbolic Computation Johannes Kepler University of Linz, Austria popov@risc.uni-linz.ac.at Outline SQL Table Creation Populating and Modifying

### <Course name> <Lesson number>-

Objectives Creating Database Triggers After completing this lesson, you should be able to do the following: Describe database triggers and their use Create database triggers Describe database trigger firing

### There are five fields or columns, with names and types as shown above.

3 THE RELATIONAL MODEL Exercise 3.1 Define the following terms: relation schema, relational database schema, domain, attribute, attribute domain, relation instance, relation cardinality, andrelation degree.

Using Subqueries to Solve Queries Objectives After completing this lesson, you should be able to do the following: Define subqueries Describe the types of problems that subqueries can solve List the types

### Unit 10: Microsoft Access Queries

Microsoft Access Queries Unit 10: Microsoft Access Queries Introduction Queries are a fundamental means of accessing and displaying data from tables. Queries used to view, update, and analyze data in different

Join Example S04.5 Join Example Cart Prod S04.6 Previous joins are equijoins (=) Other operators can be used e.g. List all my employees older than their manager SELECT emp.name FROM employee emp, manager

### Database Management Systems

Database Management Systems Practice #1 Oracle Optimizer Practice bjective Generate the executin plan fr sme SQL statements analyzing the fllwing issues: 1. access paths 2. jin rders and jin methds 3.

### ISO6 Relational Databases

ISO6 Relational Databases Simon Booth Email s.p.booth@stir.ac.uk Room Library S6 Tel: 7247 Course Aims Develop a basic proficiency in A relational database environment The SQL database language Oracle

### SQL Programming. Student Workbook

SQL Programming Student Workbook 2 SQL Programming SQL Programming Published by itcourseware, Inc., 7245 South Havana Street, Suite 100, Englewood, CO 80112 Contributing Authors: Denise Geller, Rob Roselius,

### Oracle 12c New Features For Developers

Oracle 12c New Features For Developers Presented by: John Jay King Download this paper from: 1 Session Objectives Learn new Oracle 12c features that are geared to developers Know how existing database