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

Nội dung

Appendix Practice Exam A Copyright ©2000 SYBEX , Inc., Alameda, CA www.sybex.com How 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 D Create an index Which stage comes after the Analysis stage in the application development cycle? A Implementation B Testing C Design D Development Which datatype declaration in a column would compare'MARK' and 'MARK ' as the same A VARCHAR (10) B CHAR (10) C VARCHAR2 (10) D LONG What will happen when you enter the following command at the SQL*Plus prompt? DEFINE SALARY A A user variable named SALARY is created and assigned a value of 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 Copyright ©2000 SYBEX , Inc., Alameda, CA www.sybex.com 447 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 BTS_J_C B SJC C SKJKC D S_J_C The EMPLOYEE table is defined as follows: EMP_NAME HIRE_DATE SALARY VARCHAR2(40) DATE NUMBER (14,2) Which query is most appropriate to use if you need to find the employees who were hired before 01-Jan-1998 and have a salary above 5000 or below 1000? 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; Copyright ©2000 SYBEX , Inc., Alameda, CA www.sybex.com 448 Appendix A Practice Exam What’s the error in the following code? SELECT state.st_name, st_code FROM state s WHERE st_code = 'TX'; A When tables are not joined, a table alias name cannot be used in the query B When a table alias name is defined, it must be used to qualify all the column names C If a table alias name is defined, you cannot use the table name to qualify a column D In the SELECT clause, you cannot have one column qualified and another column not qualified It should be either all columns qualified or no columns qualified The table MOVIES is defined as follows: MOVIE_ID NAME LEAD_ACTOR VIDEO_STOCK DVD_STOCK GENRE NUMBER(5) PRIMARY KEY VARCHAR2(20) VARCHAR2(15) NUMBER(3) NUMBER(3) 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 M1 WHERE 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); Copyright ©2000 SYBEX , Inc., Alameda, CA www.sybex.com 449 What is the maximum number of rows the following query can return when successfully executed? SELECT EMPNO, ENAME FROM EMP WHERE SALARY = (SELECT MAX(SALARY) FROM EMP); A B Unlimited C or D 256 10 The table MOVIES has the following data: MOVIE_ID -1245 1356 2376 6745 6644 NAME OCTOBER SKY ARMAGEDDON THE MATRIX BOWFINGER CLUELESS LEAD_ACTOR VIDEO_STOCK DVD_STOCK GENRE - - JAKE GYLLENHALL DRAMA BRUCE WILLIS 15 10 ACTION KEANU REEVES ACTION EDDIE MURPHY COMEDY ALICIA SILVERSTONE COMEDY Consider the following query, then choose the most appropriate statement SELECT name, genre FROM movies WHERE 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 Copyright ©2000 SYBEX , Inc., Alameda, CA www.sybex.com 450 Appendix A Practice Exam 11 Consider the following query that is used to select the name, salary, and dif- ference in salary from the average Choose the most appropriate option SELECT ename, sal, (sal-avgsal) diff FROM 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 NAME STREET CITY STATE ZIP PHONE TABLE ADDRESSES ( VARCHAR2 (40) PRIMARY KEY, VARCHAR2 (40), VARCHAR2 (40), CHAR (2) REFERENCES STATE (ST_CODE), NUMBER (5) NOT NULL, VARCHAR2 (12) UNIQUE); A B C D 13 Which clause in the CREATE VIEW command prevents updates to the base table through the view? 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 Copyright ©2000 SYBEX , Inc., Alameda, CA www.sybex.com 451 14 Consider the following code, then choose the most appropriate option CREATE TABLE CUSTOMER ( CUSTOMER_ID NUMBER (5), CUSTOMER_NAME VARCHAR2 (40), ZIP NUMBER (5)) AS SELECT CUST_ID, NAME, ZIP_CODE FROM CUSTOMERS 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 -L921 B023 K783 B445 D334 NAME ZIP UPD_DATE - LEEZA 75252 01-JAN-00 WILLIAMS 15215 KATHY 75252 15-FEB-00 BENJAMIN 76021 15-FEB-00 DENNIS 12443 You issue the following command to alter the table Which line of code will cause an error? ALTER TABLE CUSTOMERS MODIFY (UPD_DATE DEFAULT SYSDATE NOT NULL, ZIP NOT NULL); A Line B Line C Line D There will be no error Copyright ©2000 SYBEX , Inc., Alameda, CA www.sybex.com 452 Appendix A Practice Exam 16 Which line of code has an error? CREATE VIEW ACTION_MOVIES (NAME NOT NULL, ACTOR) AS SELECT NAME, LEAD_ACTOR FROM MOVIES WHERE GENRE = 'ACTION' ORDER BY NAME; A Line B Line C Line D There is no error 17 For which task would it be appropriate to use a FOR loop? A To assign value 50 to variable 1, if variable 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 is equal to 20 D A FOR loop is not a valid structure in PL/SQL 18 Which line of code has an error? DECLARE V_NAME VARCHAR2 (40) := 'DAVID CLARK'; V_ID NUMBER (4) := 1001; V_STATUS BOOLEAN := FALSE; BEGIN INSERT INTO EMP (ID, NAME, STATUS) VALUES (V_ID, V_NAME, V_STATUS); END; A Line B Line C Line D Line Copyright ©2000 SYBEX , Inc., Alameda, CA www.sybex.com 453 19 How 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_X NUMBER; B V_X VARCHAR2; C V_X DBTABLE.COLUMNX%TYPE; D V_X COLUMNX.DBTABLE%TYPE; 20 Evaluate the following statement What value of V_PRICE would assign the value of 'C' to V_GRADE? IF V_PRICE > 1000 THEN V_GRADE := 'A'; ELSE IF V_PRICE > 900 THEN V_GRADE := 'B'; ELSE IF V_PRICE > 800 THEN V_GRADE := 'C'; ELSE IF V_PRICE > 600 THEN V_GRADE := 'D'; ELSE V_GRADE := 'E'; END IF; END IF; END IF; END IF; 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 Copyright ©2000 SYBEX , Inc., Alameda, CA www.sybex.com 454 Appendix A Practice Exam 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 B 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 10 LOOP IF IX = THEN INSERT INTO NUMBERS VALUES (IX); ELSIF IX = THEN DELETE FROM NUMBERS; END IF; IF IX = THEN ROLLBACK; ELSE COMMIT; END IF; END LOOP; COMMIT; END; A B C D Copyright ©2000 SYBEX , Inc., Alameda, CA www.sybex.com 460 Appendix A Practice Exam 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; ROLLBACK to save_A; END; COMMIT; A 5000 B 7500 C 3000 D 25000 Copyright ©2000 SYBEX , Inc., Alameda, CA www.sybex.com 461 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; Copyright ©2000 SYBEX , Inc., Alameda, CA www.sybex.com 462 Appendix A Practice Exam 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 imme- diate They can be set to deferrable and checked initially deferred 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 Copyright ©2000 SYBEX , Inc., Alameda, CA www.sybex.com 463 43 Which statement calls dbms_utility.analyze_schema with correct named notation syntax? A dbms_utility.analyze_schema( schema->'SCOTT' ,method->'ESTIMATE'); B dbms_utility.analyze_schema( schema=|'SCOTT' ,method=|'ESTIMATE'); C dbms_utility.analyze_schema( schema-|'SCOTT' ,method-|'ESTIMATE'); D dbms_utility.analyze_schema( schema=>'SCOTT' ,method=>'ESTIMATE'); 44 Which of the following is an invalid trigger event? A after delete B before startup C after logon D after drop 45 Which of the following cannot be a field in a record? A A VARCHAR2 variable B A nested table C A %ROWTYPE record D A BOOLEAN variable Copyright ©2000 SYBEX , Inc., Alameda, CA www.sybex.com 464 Appendix A Practice Exam 46 Which line in the following PL/SQL block will raise an exception? TYPE emp_typ is RECORD ( emp_no VARCHAR2(20), name scott.emp.name%TYPE); emp_rec emp%ROWTYPE; BEGIN SELECT * INTO emp_rec FROM emp WHERE emp_no=12; emp_rec.emp_no := emp_seq.nextval; INSERT INTO emp VALUES (emp_rec); END; A Line B Line C Line D Line 47 Which line in the following PL/SQL block will raise an exception? DECLARE CURSOR stock_cur (symbol_in VARCHAR2) IS SELECT symbol, exchange, begin_date FROM stocks WHERE symbol = UPPER(symbol_in); stock_info stock_cur%ROWTYPE; BEGIN OPEN stock_cur('ORCL'); FETCH stock_cur INTO stock_info; END; A Line B Line C Line D No exception will be raised Copyright ©2000 SYBEX , Inc., Alameda, CA www.sybex.com 465 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 opera- tor in the following PL/SQL statement? 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 Copyright ©2000 SYBEX , Inc., Alameda, CA www.sybex.com 466 Appendix A Practice Exam 51 An exception is raised in line of the PL/SQL block below Where is it handled? BEGIN DECLARE timestamp DATE := 'SYSDATE'; BEGIN call_some_proc EXCEPTION WHEN VALUE_ERROR THEN dbms_output.put_line('value error'); WHEN OTHERS THEN 10 dbms_output.put_line('some other error'); 11 END; 12 EXCEPTION 13 WHEN OTHERS THEN 14 dbms_output.put_line('unknown error'); 15 END; A Line B Line C Line 13 D Lines and 13 52 In which PL/SQL section is a server error associated with a named exception? A Header B Declaration C Executable D Exception Copyright ©2000 SYBEX , Inc., Alameda, CA www.sybex.com 467 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? INVALID_DATE EXCEPTION; A An exception is declared B An exception is raised C An exception is associated D An exception is handled 55 What is done in the following PL/SQL code? PRAGMA EXCEPTION_INIT(invalid_table_name, -942); A An exception is declared B An exception is raised C An exception is associated D An exception is handled Copyright ©2000 SYBEX , Inc., Alameda, CA www.sybex.com 468 Appendix A Practice Exam 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 pre- viously defined, assigns –20123 to the SQL code for this exception, and overwrites the existing error stack with this error D Handles either the server error –20123 or the programmer-defined exception invalid_product_code Copyright ©2000 SYBEX , Inc., Alameda, CA www.sybex.com Answers to Practice Exam 469 Answers to Practice Exam 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 C Design is the next stage after Analysis The stages of application development, in order, are Analysis, Design, Development, Testing, and Implementation 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 not add spaces You cannot compare a LONG column 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.10 SQL> DEFINE SALARY DEFINE SALARY = "300.10" (CHAR) SQL> 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 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 Copyright ©2000 SYBEX , Inc., Alameda, CA www.sybex.com 470 Appendix A Practice Exam 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 D A subquery must be used here, because you want to know the high- 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 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 Copyright ©2000 SYBEX , Inc., Alameda, CA www.sybex.com Answers to Practice Exam 471 16 A When defining views, you cannot specify constraints or datatype definitions A view is a representation of data from underlying tables or views 17 B A FOR loop is used to repeat a task a fixed number of times Option A would use an IF…THEN statement; option C would use a WHILE loop Here is the code: FOR X IN 20 29 LOOP INSERT INTO TABLE_A (COLUMN1) VALUES (X); END LOOP; 18 D The INSERT statement will fail because a table cannot be created with the BOOLEAN datatype, so a BOOLEAN value cannot be directly inserted into a table The BOOLEAN value may be converted to a SQL datatype using the DECODE function before inserting 19 C By declaring a variable with %TYPE, the datatype and width are assigned at runtime The database definition may change and need not require a code change in the PL/SQL block 20 C V_PRICE greater than 800 and less than or equal to 900 would assign 'C' to V_GRADE The IF statement is evaluated from the top down 21 B When the condition or Boolean variable in the WHILE loop evalu- ates to FALSE, the loop is terminated 22 B An IF…THEN…ELSIF clause can have only one ELSE clause; it can have many ELSIF clauses 23 B One row will be added Although the loop executes six times, the value is inserted to the table only when the value of IX is When IX is 7, all rows from the table are deleted, but the operation is rolled back 24 C %NOTFOUND and %FOUND would be NULL before the first fetch They will be either TRUE or FALSE after the first fetch, depending on the fetch result 25 B SQL%FOUND and SQL%NOTFOUND will have Boolean values based on the previous SQL statement executed inside the PL/SQL block SELECT COUNT(*) will always return a value Copyright ©2000 SYBEX , Inc., Alameda, CA www.sybex.com 472 Appendix A Practice Exam 26 E When you’re referencing record variables inside an explicit cursor, you should reference the variables with the record name, not the cursor name Line 10 should read WHERE EMPNO = r_emp.empno; 27 C Options A and B not take into account the possibility of NULL values in the surcharge column 28 C GREATEST is a single-row function that takes an arbitrary number of arguments 29 B This expression will resolve as follows: LAST_DAY(ADD_MONTHS(SYSDATE,-2)) = LAST_DAY(ADD_MONTHS(1-Mar-2000,-2)) = LAST_DAY(1-Jan-2000) = 31-Jan-2000 30 A MOD will return the remainder after dividing the first argument by the second argument 31 D The format codes needed are DD, day of month; Th, ordinal modifier; "of" a text string; Month, the month name spelled out; and YYYY, the four-digit year 32 B With the VARCHAR2 datatype, trailing spaces are included in the evaluation, so Y would sort greater than X If the X and Y were the CHAR datatype, they would be equal and option C would be correct, but X and Y are VARCHAR2, so option B is correct 33 B SELECT FOR UPDATE is a DML statement The others are all DDL, which will implicitly end a transaction, but not begin one 34 D DBA_ROLE_PRIVS and DBA_SYS_PRIVS will report the GRANTEE but not the GRANTOR 35 A The savepoint save_A is set after the balance is set to 5000, and the transaction is rolled back to this savepoint twice 36 C The ALTER USER statement is used to change one or more attributes of an existing user account The IDENTIFIED BY clause specifies a password to authenticate the user Copyright ©2000 SYBEX , Inc., Alameda, CA www.sybex.com Answers to Practice Exam 473 37 A By default, when a number refers to a disk storage amount, it is measured in bytes 38 D The privilege ALL includes all the privileges that can be granted on that type of object; for a sequence, this includes select and alter The grantee public is a special user that represents any user connected to the database 39 A To remove a primary key, use the ALTER TABLE statement with the DROP PRIMARY KEY clause 40 B SYSDATE cannot be used in a check constraint 41 D The ALTER TABLE statement with the DISABLE CONSTRAINT clause is used to disable constraints 42 B Deferrable constraints are a relatively new feature in Oracle, and the default behavior for when constraints are checked is backward compatible Thus, constraints are checked immediately (not deferred) On the other hand, constraints are, by default, deferrable 43 D The correct symbol for use in named notation parameter passing is => 44 B The following events are invalid: before startup, before logon, before servererror, after shutdown, and after logoff 45 B Collections cannot be fields within a record 46 D Records can only be used in the VALUES clause of an INSERT state- ment if each field is listed individually 47 D These are all valid statements The exam may have tricky questions like this, so beware 48 D Index-by tables are the only collection that is initialized automatically; the other two must be initialized with a constructor 49 C Index-by tables can always be sparse, and nested tables can become sparse after deletions Copyright ©2000 SYBEX , Inc., Alameda, CA www.sybex.com 474 Appendix A Practice Exam 50 A Records are composed of fields and are referenced with dot notation Collections are composed of elements and are referenced with subscript notation 51 C Exceptions raised in the declaration section are handled by the enclosing block 52 B The pragma exception_init statement associates an error number with an exception name in the declaration section of a PL/SQL block 53 B Since the runtime engine has no knowledge of business rules or when to raise a programmer-defined exception, the programmer is responsible for identifying the error condition and raising the exception 54 A To create a programmer-defined exception, you declare it in the declaration section of the PL/SQL block 55 C You associate an exception name with a server error number with the PRAGMA EXCEPTION_INIT statement 56 B The RAISE_APPLICATION_ERROR procedure raises a programmer- defined exception This exception does not have to be given a name previously The number is assigned to the SQL CODE, and a TRUE in the third argument will cause the exception to be appended to the error stack rather than to overlay it Copyright ©2000 SYBEX , Inc., Alameda, CA www.sybex.com [...]... with this error D Handles either the server error –20123 or the programmer-defined exception invalid_product_code Copyright ©2000 SYBEX , Inc., Alameda, CA www.sybex.com Answers to Practice Exam 469 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... 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 Copyright ©2000 SYBEX , Inc., Alameda, CA www.sybex.com Answers to Practice Exam 471 16 A When defining views, you cannot specify constraints or datatype definitions A view is a representation of data from underlying... valid statements The exam may have tricky questions like this, so beware 48 D Index-by tables are the only collection that is initialized automatically; the other two must be initialized with a constructor 49 C Index-by tables can always be sparse, and nested tables can become sparse after deletions Copyright ©2000 SYBEX , Inc., Alameda, CA www.sybex.com 474 Appendix A Practice Exam 50 A Records are... TABLE IMAGES DROP PRIMARY KEY; B DROP PRIMARY KEY PK_IMAGES; C DROP TABLE IMAGES PRIMARY KEY; D ALTER CONSTRAINT PK_IMAGES DROP; Copyright ©2000 SYBEX , Inc., Alameda, CA www.sybex.com 462 Appendix A Practice Exam 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... the following cannot be a field in a record? A A VARCHAR2 variable B A nested table C A %ROWTYPE record D A BOOLEAN variable Copyright ©2000 SYBEX , Inc., Alameda, CA www.sybex.com 464 Appendix A Practice Exam 46 Which line in the following PL/SQL block will raise an exception? 1 2 3 4 5 6 7 TYPE emp_typ is RECORD ( emp_no VARCHAR2(20), name scott.emp.name%TYPE); emp_rec emp%ROWTYPE; BEGIN SELECT *... field x in the record symbols D The element symbol in the record akadian is assigned to the field x in the collection symbols Copyright ©2000 SYBEX , Inc., Alameda, CA www.sybex.com 466 Appendix A Practice Exam 51 An exception is raised in line 3 of the PL/SQL block below Where is it handled? 1 BEGIN 2 DECLARE 3 timestamp DATE := 'SYSDATE'; 4 BEGIN 5 call_some_proc 6 EXCEPTION 7 WHEN VALUE_ERROR THEN... EXCEPTION_INIT(invalid_table_name, -942); A An exception is declared B An exception is raised C An exception is associated D An exception is handled Copyright ©2000 SYBEX , Inc., Alameda, CA www.sybex.com 468 Appendix A Practice Exam 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,... BEGIN SELECT COUNT(*) INTO V0 FROM EMP; END; BEGIN V1 := SQL%FOUND; END; END; A NULL B TRUE C FALSE D The code will not work Copyright ©2000 SYBEX , Inc., Alameda, CA www.sybex.com 456 Appendix A Practice Exam 26 Which line of code has an error? 1 DECLARE 2 CURSOR c_emp IS SELECT empno, salary FROM emp; 3 R_emp c_emp%ROWTYPE; 4 BEGIN 5 OPEN c_emp; 6 LOOP 7 FETCH c_emp INTO r_emp; 8 EXIT WHEN c_emp%NOTFOUND;... 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 Copyright ©2000 SYBEX , Inc., Alameda, CA www.sybex.com 470 Appendix A Practice Exam 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... following SQL statement? SELECT LAST_DAY(ADD_MONTHS(SYSDATE,-2)) FROM dual; A 30-Mar-2000 B 31-Jan-2000 C 31-May-2000 D 29-Feb-2000 Copyright ©2000 SYBEX , Inc., Alameda, CA www.sybex.com 458 Appendix A Practice Exam 30 What will the following SQL statement return? SELECT MOD(25,5), MOD(8,2.5) FROM dual; A 0 and 5 B 5 and 4.5 C 0 and 2 D This will raise an exception, since MOD can only operate on integer ... invalid_product_code Copyright ©2000 SYBEX , Inc., Alameda, CA www.sybex.com Answers to Practice Exam 469 Answers to Practice Exam C A relationship between two tables is implemented in Oracle using foreign... table should have NULL values In the example, there are two rows with NULL values Copyright ©2000 SYBEX , Inc., Alameda, CA www.sybex.com Answers to Practice Exam 471 16 A When defining views,... There will be no error Copyright ©2000 SYBEX , Inc., Alameda, CA www.sybex.com 452 Appendix A Practice Exam 16 Which line of code has an error? CREATE VIEW ACTION_MOVIES (NAME NOT NULL, ACTOR) AS

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

Xem thêm

TỪ KHÓA LIÊN QUAN

w