1. Trang chủ
  2. » Công Nghệ Thông Tin

Practice exam

30 598 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 30
Dung lượng 1,03 MB

Nội dung

The table MOVIES is defined as follows: MOVIE_ID NUMBER5 PRIMARY KEY NAME VARCHAR220 LEAD_ACTOR VARCHAR215 VIDEO_STOCK NUMBER3 DVD_STOCK NUMBER3 GENRE VARCHAR28 Choose the best query t

Trang 1

A

Practice Exam

Trang 2

1. How do you implement relationships between entities of an ER diagram

in the Oracle database?

A. Create a primary key constraint

B. Create a unique key constraint

C. Create a foreign key constraint

A. A user variable named SALARY is created and assigned a value of 0

B. The value of the user-defined variable SALARY is displayed; if the variable is not defined, a message is displayed stating the variable

is not defined

C. A user variable named SALARY is created, and no value is assigned

D. The value of user-defined variable SALARY is removed

Trang 3

5. You query the database with the following:

SELECT PRODUCT_ID FROM PRODUCTS

WHERE PRODUCT_ID LIKE '%S\_J\_C' ESCAPE '\';

Choose two PRODUCT_ID strings from the options that will satisfy the query

A. SELECT emp_name FROM employee

WHERE hire_date > TO_DATE('01011998','MMDDYYYY')AND SALARY < 1000 OR > 5000;

B. SELECT emp_name FROM employee

WHERE hire_date < TO_DATE('01011998','MMDDYYYY')AND SALARY < 1000 OR SALARY > 5000;

C. SELECT emp_name FROM employee

WHERE hire_date < TO_DATE('01011998','MMDDYYYY')AND (SALARY < 1000 OR SALARY > 5000);

D. SELECT emp_name FROM employee

WHERE hire_date < TO_DATE('01011998','MMDDYYYY')AND SALARY BETWEEN 1000 AND 5000;

Trang 4

448 Appendix A  Practice Exam

7. What’s the error in the following code?

SELECT state.st_name, st_codeFROM state s

8. The table MOVIES is defined as follows:

MOVIE_ID NUMBER(5) PRIMARY KEY NAME VARCHAR2(20)

LEAD_ACTOR VARCHAR2(15) VIDEO_STOCK NUMBER(3) DVD_STOCK NUMBER(3) GENRE VARCHAR2(8)

Choose the best query that shows the name and lead actor of the movie that has the highest number in DVD_STOCK

A. SELECT NAME, LEAD_ACTOR FROM MOVIES WHERE DVD_STOCK EQUALS (SELECT MAX(DVD_STOCK) FROM MOVIES);

B. SELECT NAME, LEAD_ACTOR FROM MOVIES M1WHERE MOVIE_ID = (SELECT MOVIE_ID FROM MOVIES M2 WHERE M1.DVD_STOCK = MAX(M2.DVD_STOCK));

C. SELECT NAME, LEAD_ACTOR FROM MOVIES WHERE DVD_STOCK = MAX(DVD_STOCK);

D. SELECT NAME, LEAD_ACTOR FROM MOVIES WHERE DVD_STOCK = (SELECT MAX(DVD_STOCK) FROM MOVIES);

Trang 5

10. The table MOVIES has the following data:

MOVIE_ID NAME LEAD_ACTOR VIDEO_STOCK DVD_STOCK GENRE - - - - - -

1245 OCTOBER SKY JAKE GYLLENHALL 5 3 DRAMA

1356 ARMAGEDDON BRUCE WILLIS 15 10 ACTION

2376 THE MATRIX KEANU REEVES 8 5 ACTION

6745 BOWFINGER EDDIE MURPHY 6 COMEDY

6644 CLUELESS ALICIA SILVERSTONE 9 COMEDY

Consider the following query, then choose the most appropriate statement.SELECT name, genre

FROM moviesWHERE genre = (SELECT genre FROM movies WHERE name = 'THE MATRIX')ORDER BY 2, 1;

A. The query will result in two rows

B. You cannot use the same table name in the query and in the subquery without using a group function

C. The subquery will return more than one row; since this is a single-row subquery, the query will fail

D. The ORDER BY clause cannot be used in the query

Trang 6

450 Appendix A  Practice Exam

11. Consider the following query that is used to select the name, salary, and ference in salary from the average Choose the most appropriate option

dif-SELECT ename, sal, (sal-avgsal) diffFROM emp, (SELECT AVG(sal) avgsal FROM emp);

A. The query will fail because there is no alias name provided for the subquery in the FROM clause

B. The query will not produce the intended result because a WHERE clause is missing

C. The query will fail because the column names are not qualified

D. There is no error in the query, and the query will deliver the intended result

12. The table ADDRESSES is created using the following syntax How many indexes will be created automatically when this table is created?

CREATE TABLE ADDRESSES (NAME VARCHAR2 (40) PRIMARY KEY,STREET VARCHAR2 (40),

CITY VARCHAR2 (40),STATE CHAR (2) REFERENCES STATE (ST_CODE),ZIP NUMBER (5) NOT NULL,

PHONE VARCHAR2 (12) UNIQUE);

A. WITH CHECK OPTION

B. WITH READ ONLY

C. WITH NO UPDATE

D. There is no such option; if a user has privilege on the base table, the user can update the view

Trang 7

14. Consider the following code, then choose the most appropriate option.

CREATE TABLE CUSTOMER (

A. The code will create a table named CUSTOMER

B. Column datatypes should not be specified when creating a table from another table

C. ZIP is a reserved word and cannot be used as a column name

D. When creating a new table from an existing table, you cannot specify

a different column name

15. The table CUSTOMERS has the following data:

ID NAME ZIP UPD_DATE

3 (UPD_DATE DEFAULT SYSDATE NOT NULL,

4 ZIP NOT NULL);

Trang 8

16. Which line of code has an error?

1 CREATE VIEW ACTION_MOVIES

2 (NAME NOT NULL, ACTOR)

17. For which task would it be appropriate to use a FOR loop?

A. To assign value 50 to variable 1, if variable 2 is 100

B. To insert 10 consecutive numbers into a table starting with 20

C. To insert a record into a table until the value of variable 1 is equal to 20

D. A FOR loop is not a valid structure in PL/SQL

18. Which line of code has an error?

6 INSERT INTO EMP (ID, NAME, STATUS)

7 VALUES (V_ID, V_NAME, V_STATUS);

Trang 9

19. How do you declare a variable in the PL/SQL block, if its underlying database column datatype is not known? (The table is DBTABLE and the column name is COLUMNX.)

A. V_PRICE greater than 1000

B. V_PRICE greater than 800

C. V_PRICE between 801 and 900

D. V_PRICE between 601 and 800

Trang 10

21. What causes a WHILE loop to terminate?

A. When the condition is evaluated to NULL

B. When the condition is evaluated to FALSE

C. When the condition is evaluated to TRUE

D. The EXIT statement must always be used to terminate

22. How many ELSE clauses can an IF…THEN…ELSIF statement have?

A. 0

B. 1

C. Unlimited

D. 64

23. Consider the following PL/SQL block How many rows will be added

to the table NUMBERS when this block is executed?

BEGIN FOR IX IN 5 10 LOOP

IF IX = 6 THEN INSERT INTO NUMBERS VALUES (IX);

ELSIF IX = 7 THEN DELETE FROM NUMBERS;

END IF;

IF IX = 7 THEN ROLLBACK;

ELSE COMMIT;

Trang 11

24. If C1 is a cursor defined in a PL/SQL block, what will be the value of C1%NOTFOUND after the cursor is opened but before the first fetch?

A. TRUE

B. FALSE

C. NULL

D. None of the above

25. When the following PL/SQL block is executed, what will be the value

Trang 12

26. Which line of code has an error?

7 FETCH c_emp INTO r_emp;

8 EXIT WHEN c_emp%NOTFOUND;

9 UPDATE EMP SET SALARY = SALARY + 500

10 WHERE EMPNO = c_emp.empno;

Trang 13

27. Using the following INVENTORY table instance chart, choose the SQL statement that will increase the base price of all items by 3% of the combined base_price and surcharge.

A. update inventory set base_price = (base_price + surcharge) * 1.03;

B. update inventory set base_price = base_price * 1.03 + surcharge * 1.03;

C. update inventory set base_price = (base_price * 1.03) + NVL(surcharge,0)* 1.03;

D. None of these statements will achieve the desired results

28. Which of the following is not a group function?

Trang 14

30. What will the following SQL statement return?

SELECT MOD(25,5), MOD(8,2.5) FROM dual;

Which of the following expressions will satisfy these requirements?

A. to_char(start_date,'Dsp of Month, YYYY')

B. to_char(start_date,'DDTh of Month, YYYY')

C. to_char(start_date,'DTh "of" Month, YYYY')

D. to_char(start_date,'DDTh "of" Month, YYYY')

32. What will be displayed from the following PL/SQL block?

END IF;

IF Y >= X THEN dbms_output.put_line('Y is greater');

END IF;

END;

A. X is greater

B. Y is greater

C. Both X is greater and Y is greater

D. Neither X is greater nor Y is greater

Trang 15

33. Which statement will implicitly begin a transaction?

Trang 16

35. What is the value of BALANCE in the CHECKING table for ACCOUNT_ID 'A' after the following PL/SQL block?BEGIN

UPDATE checking SET balance = 5000 WHERE account_id = 'A';

SAVEPOINT save_A;

UPDATE checking SET balance = 7500 WHERE account_id = 'A';

SAVEPOINT save_A2;

UPDATE checking SET balance = 3000 WHERE account_id = 'A';

SAVEPOINT save_A3;

ROLLBACK TO SAVEPOINT save_A;

UPDATE brokerage SET cash_bal = 25000 WHERE account_id = 'A';

SAVEPOINT save_X;

ROLLBACK to save_X;

Trang 17

36. What does the following SQL statement do?

ALTER USER sherry IDENTIFIED BY ann;

A. Creates user ann with the password of sherry

B. Creates user sherry with the password of ann

C. Changes the password to ann for user sherry

D. Changes the password to sherry for user ann

37. What does the following SQL statement do?

ALTER USER tommy QUOTA 2500 ON tools;

A. Sets user tommy’s quota in tablespace tools to 2500 bytes

B. Sets user tommy’s quota in tablespace tools to 2500 kilobytes

C. Sets user tommy’s quota in tablespace tools to 2500 megabytes

D. Changes user tommy’s privileges on the table tools

38. If emp_seq is a sequence, what does the following SQL statement do?GRANT ALL ON emp_seq TO public;

A. Gives user public permission to select from the sequence emp_seq

B. Gives user public permission to select or alter the sequence emp_seq

C. Gives any user permission to select from the sequence emp_seq

D. Gives any user permission to select or alter the sequence emp_seq

39. Which statement will remove the primary key PK_IMAGES from the table IMAGES?

A. ALTER TABLE IMAGES DROP PRIMARY KEY;

B. DROP PRIMARY KEY PK_IMAGES;

C. DROP TABLE IMAGES PRIMARY KEY;

D. ALTER CONSTRAINT PK_IMAGES DROP;

Trang 18

40. Which of the following check constraints is invalid?

A. CONSTRAINT CHECK (gender in ('M','F'))

B. CONSTRAINT CHECK (due_date > SYSDATE);

C. CONSTRAINT CHECK (bonus < salary)

D. CONSTRAINT CHECK (approval_code LIKE 'A%')

41. Which statement will disable the unique constraint SSN_uniq on the EMP table?

A. ALTER TABLE EMP DISABLE SSN_uniq;

B. ALTER CONSTRAINT SSN_uniq ON TABLE EMP DISABLE;

C. DISABLE CONSTRAINT SSN_uniq;

D. ALTER TABLE EMP DISABLE CONSTRAINT SSN_uniq;

42. Which option best describes when constraints are checked and the deferrability of constraint checking?

A. By default, constraints are nondeferrable and checked initially diate They can be set to deferrable and checked initially deferred

imme-B. By default, constraints are deferrable and checked initially immediate They can be set to nondeferrable and checked initially deferred

C. By default, constraints are deferrable and checked initially deferred They can be set to nondeferrable and checked initially immediate

D. By default, constraints are nondeferrable and checked initially deferred They can be set to deferrable and checked initially immediate

Trang 19

43. Which statement calls dbms_utility.analyze_schema with correct named notation syntax?

Trang 20

46. Which line in the following PL/SQL block will raise an exception?

1 TYPE emp_typ is RECORD ( emp_no VARCHAR2(20), name scott.emp.name%TYPE);

WHERE symbol = UPPER(symbol_in);

Trang 21

48. Which collection type must be explicitly initialized with a constructor?

A. Index-by table

B. Nested table

C. VARRAY

D. Nested table and VARRAY

49. Which collection type can be sparse?

A. Index-by table

B. Nested table and VARRAY

C. Nested table and index-by table

D. VARRAY

50. What type of data structure is on either side of the assignment tor in the following PL/SQL statement?

opera-symbols(x) := akadian.symbol;

A. The field symbol in the record akadian is assigned to the element

x in the collection symbols.

B. The field akadian in the record symbol is assigned to the element

x in the collection symbols.

C. The element symbol in the collection akadian is assigned to the

field x in the record symbols.

D. The element symbol in the record akadian is assigned to the field

x in the collection symbols.

Trang 22

51. An exception is raised in line 3 of the PL/SQL block below Where is

9 WHEN OTHERS THEN

10 dbms_output.put_line('some other error');

Trang 23

53. What type of exception requires a RAISE statement?

A. A named server exception

B. A programmer-defined exception

C. An unnamed server exception

D. The RAISE statement is never required for an exception

54. What is done in the following PL/SQL code?

Trang 24

56. What does the following PL/SQL block do?

RAISE_APPLICATION_ERROR(-20123, 'invalid_product_code', TRUE)

A. Raises the previously defined exception invalid_product_code, with a SQL code of –20123, appending this error to the existing error stack

B. Raises a programmer-defined exception, that does not have to

be previously defined, assigns –20123 to the SQL code for this exception, and appends the error to the existing error stack

C. Raises a programmer-defined exception, that does not have to be viously defined, assigns –20123 to the SQL code for this exception, and overwrites the existing error stack with this error

pre-D. Handles either the server error –20123 or the programmer-defined exception invalid_product_code

Trang 25

Answers to Practice Exam

1. C A relationship between two tables is implemented in Oracle using foreign key (referential integrity) constraints Foreign keys make sure that the value entered in one table is valid against its parent table

2. C Design is the next stage after Analysis The stages of application development, in order, are Analysis, Design, Development, Testing, and Implementation

3. B The CHAR datatype fills the width of the column with spaces if the length of the column data is less than its length Using CHAR, 'MARK' and 'MARK ' are the same VARCHAR and VARCHAR2 store only the data and do not add spaces You cannot compare a LONG column

4. B DEFINE is used to declare a CHAR datatype variable or to display its value if no value is provided For example, DEFINE SALARY = 300.10 would create a variable named SALARY and assign a CHAR value of 300.10 to it Using DEFINE SALARY would display its value You can use these variables in queries The variable name should be preceded

by an ampersand (&SALARY):

SQL> DEFINE SALARY = 300.10SQL> DEFINE SALARY

DEFINE SALARY = "300.10" (CHAR)SQL>

5. A, D The substitution character % may be substituted for zero or for many characters The substitution character _ does not have any effect in this query because an escape character precedes it, so it is treated as a literal

6. C You have two main conditions in the question: one on the hire date and the other on the salary So, you should use an AND operator In the second part, you have two options: The salary can be either more than

5000 or less than 1000 So, the second part should be enclosed in parentheses and use an OR operator Option B is similar to option C except for the parentheses, but the difference changes the meaning completely Option B would select the employees who were hired before 01-Jan-1998 or have a salary above 5000 or have a salary below 1000

Trang 26

7. C An alias name S is defined for the table STATE Therefore, to qualify

a column, only S can be used You should not use the table name to qualify the column Note that in this query, because data is selected from only one table, there is no need to qualify the column names at all

8. D A subquery must be used here, because you want to know the est value in the DVD_STOCK column, and then use this value to get the name and lead actor of the movie Option C conveys the same meaning, but you cannot use a GROUP function in the WHERE clause

high-9. B The query can return an unlimited number of rows Since the equality operator is used for the subquery, the subquery can return only one row

10. A There is no error in the statement, and the query will return two rows The subquery returns only one row with a value of 'ACTION', and the main query returns the name and genre of the two ACTION movies

11. D There is no error It is not necessary to have an alias name provided for the subquery in the FROM clause An alias name would improve the readability of the query Column names must be qualified only if there

is an ambiguity

12. C Oracle creates unique indexes for each unique key and primary key defined in the table The table ADDRESSES has one unique key and a primary key Indexes will not be created for NOT NULL or foreign key constraints

13. B The WITH READ ONLY option in the CREATE VIEW command is used to prevent any INSERT, UPDATE, or DELETE statements applied to the base table through the view WITH CHECK OPTION is used to restrict the updates

or inserts to the view

14. B When creating a table using a subquery, column datatypes should not be specified The datatypes are derived by Oracle from the data selected or based on the base table You may specify a column name and constraints for the new table

15. B When you’re altering an existing column to add a NOT NULL constraint,

no rows in the table should have NULL values In the example, there are two rows with NULL values

Ngày đăng: 04/12/2015, 07:52

Xem thêm

TỪ KHÓA LIÊN QUAN

w