Você está na página 1de 4

Name: _______________________________ QUIZ 1 IT133 - _____ DATE: ____ ___, 2011 Instructions: Retrieve the required information for

Part II using SQL language. Write all answers in your test booklet LEGIBLY. No Cheating!! Part I. Identification.

1. An operation that retrieves data from one or more tables or views.

2. SEQUEL, which stands for ( 2 ) was developed by ( 3 ) and ( 4 ) at IBM to manipulate and retrieve data stored in IBM's original relational database management system, System R. 5. Which clause conditionally restricts the rows that get displayed? 6. Which clause conditionally restricts the groups that get displayed? 7. Only columns listed in the GROUP BY clause may appear in the SELECT list aside from _______. 8. Type of SQL statements that lets you analyze information on a table, index, or cluster. 9. Type of SQL statements that lets you add comments to the data. 10.Type of SQL statements that lets you access and manipulate data in existing schema objects. 11.Type of SQL statements that lets you manage changes made by DML statements. 12.Type of SQL statements that lets you dynamically manage the properties of an Oracle database instance. 13.Which kind of datatype contains atomic values? 14.Which kind of datatype contains sets of values? 15.Set operator that returns only the distinct rows that appear in either result. 16.Set operator that returns all rows returned by both queries. 17.Set operator that returns only the rows returned by both queries. 18.Set operator that returns only the unique rows returned by the first query but not by the second query. 19.A query that combines rows from two or more tables or views. 20.Queries containing set operators are called ______.
Part II. Use the database schema of a soccer database as described in the following picture.

1. Retrieve the number of games Mr. James Younghusband has played for Team Askals in his current contract. 2. Retrieve which teams played against each other that had the entire stadium packed with more than its normal capacity. 3. Retrieve the names of fans that support the same team going to the Juggernaut Bar. 4. Which team had the earliest practice training in June at the Wynn Stadium? 5. How many games have been played between Manchester United and Internazionale Milano over this season? 6. How many combined years of experience does all of the coaches in each team have? 7. Which team had the least games played for this years World Cup? 8. Who is the coach with the most experience for Celtic Glasgow? Name: _______________________________ IT133 AT4 Signature: _______________________________ August 22, 2011 Instructions: Write all answers in your test booklet LEGIBLY. No Cheating!! Part I. Evaluating SQL. Write the result of the query, if any. Indicate Error if you believe it will not execute, and No Rows Returned if it should not return anything. For clarity, indicate every space as in your answer. Refer the table instances below for queries referring to txt_tab:
TAB_TXT txt_n o 1 2 3 5 8 this text is complete MY saved text HAS been changed I can save alpha-numeric values like these a1b2c3d4e5 ADM rocks! THEWHOLEUNIVERSEWASINAHOTDENSESTATEthen
5.

my_txt

cre_dt 01-AUG-11 05-AUG-11 07-AUG-11 19-AUG-11 21-AUG-11


WHERE cre_dt = TO_DATE(07 AUGUST 2011 , Month DD YYYY)

1. 2.
3.

SELECT LENGTH(mytxt) FROM tab_txt WHERE txt_no = 8 SELECT SUBSTR(my_txt, -7, 4) FROM tab_txt WHERE txt_no = 5 SELECT MAX(txt_no) FROM tab_txt WHERE cre_dt > SYSDATE - 5 SELECT REPLACE(my_txt, TH, 88) FROM tab_txt WHERE cre_dt = SYSDATE 1

SELECT TO_NUMBER(SUBSTR(mytxt, 53, 1)) FROM tab_txt WHERE txt_no = 3 SELECT SYSDATE FROM tab_txt SELECT AVG(LENGTH(txt_no)) FROM tab_txt SELECT my_txt FROM tab_txt

6. 7. 8.

9.

SELECT TO_CHAR(cre_dt, Month YY DDspth) FROM tab_txt

10. SELECT * FORM tab_txt WHERE txt_no = 1 11. SELECT TO_CHAR(SYSDATE, DD) FROM dual

4.

Use the database schema of a company as described in the following picture.

WHERE EXISTS (SELECT txt_no FROM tab_txt

WHERE 1=2)

9. Retrieve the names of employees who work on every project. 10. Retrieve the names of employees who do not work on any project. 11. Find the names and addresses of employees who work on at least one project located in Houston but whose department has no location in Houston. 12. Find details of those employees whose salary is > the average salary for all employees in his/her department. Output salary in ascending order. 13. Among employees in department 80, which ones work on a project for other departments? 14. List the employees (ssn) who have worked for more than 160 hours on at least 2 projects and have also worked on a project where Mel D. Thyne was manager (not the same as the 160hr projects). 15. Which manager employee (full name and ssn) has been a manager for the same department the longest? Name: _______________________________ QUIZ 4 IT133 - _____ DATE: ____ ___, 2011 Instructions: PL/SQL. Write all answers in your test booklet LEGIBLY. No Cheating!! Using HR/HR Schema:

1. Create a Procedure or Function that will ask for the employee ID and display all employee details (employees.*), the employees job history in ascending order (start date, end date, position held), and: Total years with the company Create the anonymous block to invoke your procedure/function.

2. Create a function that requires an employee id, and returns the number of jobs an employee has
had within the company as this text has had N job positions since hire_date . Display has been job_title since hire_date when the employee has had the same job since starting with the company. 3. Create a procedure that will invoke the function in #2 for every employee within a given department ID (as procedure parameter). Always display the department name first before invoking your function. If there are no employees within the department, the display should be: No employees in the department yet. Include employee name and ID in the output. Use: explicit cursors (d-o-f-c, at least once) and any other constructs.

Você também pode gostar