oracle mid exam

40
1. A table must have a primary key. True or False? Mark for Review (1) Points True False (*) Incorrect. Refer to Section 11 Lesson 1. 2. A foreign key cannot refer to a primary key in the same table. True or False? Mark for Review (1) Points True False (*) Correct 3. The text below is an example of what constraint type?

Upload: zuzudeeia

Post on 20-Jan-2016

2.935 views

Category:

Documents


0 download

DESCRIPTION

Oracle mid exam

TRANSCRIPT

Page 1: Oracle mid exam

1. A table must have a primary key. True or False? Mark for Review

(1) Points

True

False (*)

Incorrect. Refer to Section 11 Lesson 1.

2. A foreign key cannot refer to a primary key in the same table. True or False? Mark for Review

(1) Points

True

False (*)

Correct

3. The text below is an example of what constraint type?

If the number of BOOKS lent to a BORROWER in the LIBRARY exceeds 5, then we must send him a letter requesting the return of the BOOKS; this will require extra programming to enforce.

Mark for Review

(1) Points

Page 2: Oracle mid exam

Entity integrity

User-defined integrity (*)

Column integrity

Referential integrity

Correct

4. A table must have at least one candidate key, as well as its primary key. True or False? Mark for Review

(1) Points

True

False (*)

Correct

5. Foreign keys must be null. True or False? Mark for Review

(1) Points

True

Page 3: Oracle mid exam

False (*)

Correct

6. Which of the following is a valid reason for considering a Subtype Implementation? Mark for Review

(1) Points

The resulting table will reside in a single database and be used by just ONE user.

The common access paths for the supertypes are different.

Business functionality, business rules, access paths, and frequency of access are all very different between the subtypes. (*)

Most of the relationships are at the supertype level.

Incorrect. Refer to Section 11 Lesson 4.

7. In a physical data model, a relationship is represented as a combination of: (Choose Two) Mark for Review

(1) Points

(Choose all correct answers)

Page 4: Oracle mid exam

Column

Primary Key or Unique Key (*)

Check Constraint or Unique Key

Foreign Key (*)

Correct

8. The transformation from an ER diagram to a physical design involves changing terminology. Secondary Unique Identifiers become Mark for Review

(1) Points

Columns

Tables

Unique Constraints (*)

Primary Key Constraints

Correct

Page 5: Oracle mid exam

9. Attributes become tables in a database. True or False? Mark for Review

(1) Points

True

False (*)

Incorrect. Refer to Section 11 Lesson 2.

10. To resolve a many to many relationship in a physical model you create a/an ___________________? Mark for Review

(1) Points

Unique key constraints

Intersection entity

Intersection table (*)

Two tables with Foreign key constraints between them

Correct

Section 11

Page 6: Oracle mid exam

(Answer all questions in this section)

11. In a conceptual model, many-to-many relationships are resolved via a structure called a/an: ________________ Mark for Review

(1) Points

Supertype

Intersection Table

Intersection Entity (*)

Subtype

Incorrect. Refer to Section 11 Lesson 3.

Section 12

(Answer all questions in this section)

12. During which phases of the System Development Life Cycle would you test the system before rolling it out to the users? Mark for Review

(1) Points

Build and Transition

Page 7: Oracle mid exam

Strategy and Analysis

Design and Production

Transition and Production (*)

Correct.

13. In the Analysis phase, the tables are created and populated with test data. True or False? Mark for Review

(1) Points

True

False (*)

Correct.

14. What command can be used to create a new row in a table in the database? Mark for Review

(1) Points

CREATE

Page 8: Oracle mid exam

NEW

ADD

INSERT (*)

Correct.

15. The _______ clause can be added to a SELECT statement to return a subset of the data. Mark for Review

(1) Points

ANYWHERE

WHICH

WHERE (*)

EVERY

Correct.

16. What command will return data from the database to you? Mark for Review

(1) Points

Page 9: Oracle mid exam

FETCH

GET

SELECT (*)

RETURN

Correct.

17. The SQL statement ALTER TABLE EMPLOYEES DELETE COLUMN SALARY is a valid statement. True or False? Mark for Review

(1) Points

True

False (*)

Correct.

18. The f_customers table contains the following data:

ID Name Address City State Zip

1 Cole Bee 123 Main Street Orlando FL 32838

Page 10: Oracle mid exam

2 Zoe Twee 1009 Oliver Avenue Boston MA 02116

3 Sandra Lee 22 Main Street Tampa FL 32444

If you run the following statement:

DELETE FROM F_CUSTOMERS WHERE ID <= 2;

How many rows will be left in the table?

Mark for Review

(1) Points

0

3

1 (*)

2

Correct.

Section 15

(Answer all questions in this section)

Page 11: Oracle mid exam

19. You want to create a list of all albums that have been produced by the company. The list should include the title of the album, the artist's name, and the date the album was released. The ALBUMS table includes the following columns:

ALB_TITLE VARCHAR2(150) NOT NULL

ALB_ARTIST VARCHAR2(150) NOT NULL

ALB_DATE DATE NOT NULL

Which statement can you use to retrieve the necessary information?

Mark for Review

(1) Points

SELECT *

FROM albums;

(*)

SELECT alb_title, alb_artist, alb_dates

FROM album;

SELECT alb_title, alb_artist, alb_dates

FROM albums;

SELECT alb_title; alb_artist; alb_date

FROM albums;

Page 12: Oracle mid exam

Incorrect. See Section 15 Lesson 1.

20. When you use the SELECT clause to list one or two columns only from a table and no WHERE clause, which SQL capability is used? Mark for Review

(1) Points

Joining only

Selection only

Projection only (*)

Projection and Selection

Correct.

Section 15

(Answer all questions in this section)

21. The EMPLOYEES table contains these columns:

SALARY NUMBER(7,2)

BONUS NUMBER(7,2)

COMMISSION_PCT NUMBER(2,2)

Page 13: Oracle mid exam

All three columns contain values greater than zero.

There is one row of data in the table and the values are as follows:

Salary = 500, Bonus = 50, Commission_pct = .5

Evaluate these two SQL statements:

1.

SELECT salary + bonus + commission_pct * salary - bonus AS income

FROM employees;

2.

SELECT (salary + bonus ) + commission_pct * (salary - bonus) income

FROM employees;

What will be the result?

Mark for Review

(1) Points

Statement 1 will return a higher value than statement 2.

Statement 2 will return a higher value than statement 1. (*)

Statement 1 will display a different column heading.

One of the statements will NOT execute.

Page 14: Oracle mid exam

Incorrect. See Section 15 Lesson 1.

22. In which clause of a SELECT statement would you specify the name of the table or tables being queried? Mark for Review

(1) Points

The FROM clause (*)

The SELECT clause

The WHERE clause

Any of the above options; you can list tables wherever you want in a SELECT statement.

Correct.

23. If a SQL statement returns data from two or more tables, which SQL capability is being used? Mark for Review

(1) Points

Selection

Projection

Joining (*)

Page 15: Oracle mid exam

Insertion

Correct.

24. In the default order of precedence, which operator would be evaluated first? Mark for Review

(1) Points

Subtractions and Additions are at the same level and would be evaluated first based on left to right order

Multiplications and Divisions are at the same level and would be evaluated first based on left to right order (*)

Additions and Multiplications are at the same level and would be evaluated first based on left to right order

Divisions and Subtractions are at the same level and would be evaluated first based on left to right order

Correct.

Section 16

Page 16: Oracle mid exam

(Answer all questions in this section)

25. The EMPLOYEES table contains these columns:

LAST_NAME VARCHAR2(25)

FIRST_NAME VARCHAR2(25)

EMAIL VARCHAR2(50)

You are writing a SELECT statement to retrieve the names of employees that have an email address.

SELECT last_name||', '||first_name "Employee Name"

FROM employees;

Which WHERE clause should you use to complete this statement?

Mark for Review

(1) Points

WHERE email = NULL;

WHERE email != NULL;

WHERE email IS NULL;

WHERE email IS NOT NULL; (*)

Incorrect. See Section 16 Lesson 3.

Page 17: Oracle mid exam

26. If you write queries using the BETWEEN operator, it does not matter in what order you enter the values, i.e. BETWEEN low value AND high value will give the same result as BETWEEN high value and low value. True or False? Mark for Review

(1) Points

True

False (*)

Correct.

27. Where in a SQL statement can you not use arithmetic operators? Mark for Review

(1) Points

SELECT

FROM (*)

WHERE

NONE

Correct.

Page 18: Oracle mid exam

28. You need to display employees whose salary is in the range of 10000 through 25000 for employees in department 50 . What does the WHERE clause look like? Mark for Review

(1) Points

WHERE department_id < 50 <br> AND salary BETWEEN 10000 AND 25000

WHERE department_id > 50

AND salary BETWEEN 10000 AND 25000

WHERE department_id = 50

AND salary BETWEEN 25001 AND 10001

WHERE department_id = 50

AND salary BETWEEN 10000 AND 25000

(*)

Correct.

29. When using the LIKE condition to search for _ symbols, which character can you use as the default ESCAPE option? Mark for Review

(1) Points

Page 19: Oracle mid exam

%

^

&

\ (*)

Correct.

30. Which comparison condition would you use to select rows that match a character pattern? Mark for Review

(1) Points

IN

LIKE (*)

ALMOST

SIMILAR

Correct.

Page 20: Oracle mid exam

31. You need to display all the rows in the EMPLOYEES table that contain a null value in the DEPARTMENT_ID column. Which comparison operator should you use? Mark for Review

(1) Points

"= NULL"

NULL!

ISNULL

IS NULL (*)

Correct.

32. Which operator is used to combine columns of character strings to other columns? Mark for Review

(1) Points

*

/

+

|| (*)

Page 21: Oracle mid exam

Correct.

33. If the EMPLOYEES table has the following columns, and you want to write a SELECT statement to return the employee last name and department number for employee number 176, which of the following SQL statements should you use?

Name Type Length

EMPLOYEE_ID NUMBER 22

FIRST_NAME VARCHAR2 20

LAST_NAME VARCHAR2 25

EMAIL VARCHAR2 25

PHONE_NUMBER VARCHAR2 20

SALARY NUMBER 22

COMMISSION_PCT NUMBER 22

MANAGER_ID NUMBER 22

DEPARTMENT_ID NUMBER 22

Mark for Review

(1) Points

SELECT last_name, department_id

FROM employees

WHERE employee_id = 176;

(*)

Page 22: Oracle mid exam

SELECT last_name, department_id

FROM employees

WHERE employee_id equals 176;

SELECT first_name, employee_id

FROM employees

WHERE employee_id = 176;

SELECT last_name, employee_id

FROM employees

WHERE employee_id equals 176;

Correct.

34. Evaluate this SELECT statement:

SELECT *

FROM employees

WHERE department_id IN(10, 20, 30)

AND salary > 20000;

Which values would cause the logical condition to return TRUE?

Mark for Review

Page 23: Oracle mid exam

(1) Points

DEPARTMENT_ID = 10 and SALARY = 20000

DEPARTMENT_ID = 20 and SALARY = 20000

DEPARTMENT_ID = null and SALARY = 20001

DEPARTMENT_ID = 10 and SALARY = 20001 (*)

Correct.

35. You need to display all the employees whose last names (of any length) start with the letters 'Sm' . Which WHERE clause should you use? Mark for Review

(1) Points

WHERE last_name LIKE 'Sm%' (*)

WHERE last_name LIKE '%Sm'

WHERE last_name LIKE '_Sm'

WHERE last_name LIKE 'Sm_'

Incorrect. See Section 16 Lesson 2.

Page 24: Oracle mid exam

36. You want to determine the orders that have been placed by customers who reside in the city of Chicago. You write this partial SELECT statement:

SELECT orderid, orderdate, total

FROM orders;

What should you include in your SELECT statement to achieve the desired results?

Mark for Review

(1) Points

AND city = Chicago;

AND city = 'Chicago';

WHERE city = 'Chicago'; (*)

WHERE city = Chicago;

Correct.

Section 17

(Answer all questions in this section)

Page 25: Oracle mid exam

37. From left to right, what is the correct order of Precedence? Mark for Review

(1) Points

Arithmetic, Concatenation, Comparison, OR (*)

NOT, AND, OR, Arithmetic

Arithmetic, NOT, Logical, Comparison

Arithmetic, NOT, Concatenation, Logical

Correct.

38. Which comparison condition means "Less Than or Equal To"? Mark for Review

(1) Points

"=)"

"+<"

">="

"<=" (*)

Page 26: Oracle mid exam

Correct.

39. Which statement about the ORDER BY clause is true? Mark for Review

(1) Points

You can use a column alias in the ORDER BY clause. (*)

The default sort order of the ORDER BY clause is descending.

The ORDER BY clause can only contain columns that are included in the SELECT list.

The ORDER BY clause should immediately precede the FROM clause in a SELECT statement

Correct.

40. Which of the following are TRUE regarding the logical AND operator? Mark for Review

(1) Points

TRUE AND TRUE return FALSE

TRUE AND FALSE return TRUE

FALSE AND TRUE return NULL

Page 27: Oracle mid exam

TRUE AND FALSE return FALSE (*)

Correct.

Section 17

(Answer all questions in this section)

41. Which logical operator returns TRUE if either condition is true? Mark for Review

(1) Points

OR (*)

AND

NOT

BOTH

Correct.

42. Which statement about the default sort order is true? Mark for Review

(1) Points

The lowest numeric values are displayed last.

Page 28: Oracle mid exam

The earliest date values are displayed first. (*)

Null values are displayed first.

Character values are displayed in reverse alphabetical order.

Correct.

43. What value will the following SQL statement return?

SELECT employee_id

FROM employees

WHERE employee_id BETWEEN 100 AND 150

OR employee_id IN(119, 175, 205)

AND (employee_id BETWEEN 150 AND 200);

Mark for Review

(1) Points

19

No rows will be returned

100, 101, 102, 103, 104, 107, 124, 141, 142, 143, 144, 149 (*)

Page 29: Oracle mid exam

200, 201, 202, 203, 204, 205, 206

Correct.

44. Evaluate this SELECT statement:

SELECT first_name, last_name, email

FROM employees

ORDER BY last_name;

Which statement is true?

Mark for Review

(1) Points

The rows will not be sorted.

The rows will be sorted alphabetically by the LAST_NAME values. (*)

The rows will be sorted in reverse alphabetical order by the LAST_NAME values.

The rows will be sorted alphabetically by the FIRST_NAME and then the LAST_NAME values

Correct.

Page 30: Oracle mid exam

45. You query the database with this SQL statement:

SELECT price

FROM products

WHERE price IN(1, 25, 50, 250)

AND (price BETWEEN 25 AND 40 OR price > 50);

Which two values could the statement return? (Choose two.)

Mark for Review

(1) Points

(Choose all correct answers)

1

50

25 (*)

10

250 (*)

Correct.

46. You need to create a report to display all employees that were hired on or before January 1, 1996. The data should display in this format:

Page 31: Oracle mid exam

Employee Start Date and Salary

14837 - Smith 10-MAY-1992 / 5000

Which SELECT statement could you use?

Mark for Review

(1) Points

SELECT employee_id || - || last_name "Employee",

hire_date || / || salary "Start Date and Salary

FROM employees

WHERE hire_date <= '01-JAN-1996';

SELECT employee_id ||' '|| last_name "Employee",

hire_date ||' '|| salary "Start Date and Salary"

FROM employees

WHERE hire_date <= 01-JAN-1996';

SELECT employee_id ||'"- "|| last_name "Employee",

hire_date ||" / "|| salary Start Date and Salary"

FROM employees

WHERE hire_date <= '01-JAN-1996';

SELECT employee_id ||' - '|| last_name 'Employee',

Page 32: Oracle mid exam

hire_date ||' / '|| salary 'Start Date and Salary"

FROM employees

WHERE hire_date <= '01-JAN-1996';

SELECT employee_id ||' - '|| last_name "Employee",

hire_date ||' / '|| salary "Start Date and Salary"

FROM employees

WHERE hire_date <= '01-JAN-1996';

(*)

Correct.

47. Which SELECT statement should you use to limit the display of product information to those products with a price of less than 50? Mark for Review

(1) Points

SELECT product_id, product_name

FROM products

WHERE price < 50;

(*)

SELECT product_id, product_name

FROM products

Page 33: Oracle mid exam

HAVING price < 50;

SELECT product_id, product_name

FROM products

WHERE price <= 50;

SELECT product_id, product_name

FROM products

GROUP BY price < 50;

SELECT product_id, product_name

FROM products

WHERE price < 50.00

GROUP BY price;

Correct.

48. Evaluate this SQL statement:

SELECT e.employee_id, e.last_name, e.first_name, m.manager_id

FROM employees e, employees m

ORDER BY e.last_name, e.first_name

Page 34: Oracle mid exam

WHERE e.employee_id = m.manager_id;

This statement fails when executed. Which change will correct the problem?

Mark for Review

(1) Points

Reorder the clauses in the query. (*)

Remove the table aliases in the WHERE clause.

Remove the table aliases in the ORDER BY clause.

Include a HAVING clause.

Correct.

49. The EMPLOYEES table contains these columns:

EMPLOYEE_ID NUMBER(9) PK

LAST_NAME VARCHAR2(25)

FIRST_NAME VARCHAR2(25)

DEPARTMENT_ID NUMBER(9)

Compare these two SQL statements:

1.

SELECT DISTINCT department_id DEPT, last_name, first_name

Page 35: Oracle mid exam

FROM employees

ORDER BY department_id;

2.

SELECT department_id DEPT, last_name, first_name

FROM employees

ORDER BY DEPT;

How will the results differ?

Mark for Review

(1) Points

One of the statements will return a syntax error.

One of the statements will eliminate all duplicate DEPARTMENT_ID values.

There is no difference in the result between the two statements.

The statements will sort on different column values. (*)

Incorrect! See Section 17 Lesson 3.

50. The PLAYERS table contains these columns:

PLAYERS TABLE:

LAST_NAME VARCHAR2 (20)

Page 36: Oracle mid exam

FIRST_NAME VARCHAR2 (20)

SALARY NUMBER(8,2)

TEAM_ID NUMBER(4)

MANAGER_ID NUMBER(9)

POSITION_ID NUMBER(4)

You want to display all players' names with position 6900 or greater.

You want the players names to be displayed alphabetically by last name and then by first name.

Which statement should you use to achieve the required results?

Mark for Review

(1) Points

SELECT last_name, first_name

FROM players

WHERE position_id >= 6900

ORDER BY last_name, first_name;

(*)

SELECT last_name, first_name

FROM players

WHERE position_id > 6900

ORDER BY last_name, first_name;

SELECT last_name, first_name

FROM players

Page 37: Oracle mid exam

WHERE position_id <= 6900

ORDER BY last_name, first_name;

SELECT last_name, first_name

FROM players

WHERE position_id >= 6900

ORDER BY last_name DESC, first_name;

Correct.