Вы находитесь на странице: 1из 17

What three attributes do you define for each passed parameter in a stored procedure definition?

Choice 1 mode (in, out, or inout), variable name, field length Choice 2 database schema, mode (in, out, or inout), variable name Choice 3 mode (in, out, or inout), variable name, data type Choice 4 variable name, input data type, return data type Choice 5 host variable name, data type, language Which one of the following releases a page lock? Choice 1 COMMIT Choice 2 ACQUIRE Choice 3 DEALLOCATE Choice 4 RELEASE Choice 5 DELETE In what order do you perform the following cursor operations? Choice 1 OPEN, DECLARE, CLOSE, FETCH Choice 2 OPEN, DECLARE, FETCH, CLOSE Choice 3 OPEN, FETCH, DECLARE, CLOSE Choice 4 DECLARE, OPEN, CLOSE Choice 5 DECLARE, OPEN, FETCH, CLOSE What data type do you use to store a photograph? Choice 1 VARGRAPHIC Choice 2 CLOB Choice 3 GRAPHIC Choice 4 BLOB Choice 5 DBCLOB

Referring to the above situation, what program action do you specify? Choice 1 Issue the ROLLBACK command to remove the first update. Choice 2 Terminate the program with an error message. Choice 3 Delete the record that was affected by the first update. Choice 4 Continue processing the transaction. Choice 5 Save the first transaction so the user knows which table was updated.

What type of table do you use to pass SQL result sets between programs? Choice 1 Result table Choice 2 Materialized query table Choice 3 Empty table Choice 4 Temporary table Choice 5 Base table SAVEPOINT spt1 ON ROLLBACK RETAIN CURSORS; DELETE FROM my_table; SAVEPOINT spt2 ON ROLLBACK RETAIN CURSORS; INSERT INTO my_table (col1) VALUES (:hv1); SAVEPOINT spt3 ON ROLLBACK RETAIN CURSORS; INSERT INTO my_table (col1) VALUES (:hv2); ROLLBACK TO SAVEPOINT spt2;

If table my_table has 20 rows before the above code is executed, how many rows are in the table afterwards? Choice 1 0 Choice 2 1 Choice 3 2 Choice 4 20 Choice 5 22

Two tables must both be updated for a valid transaction. After the first update completes, the second update fails.

Which one of the following is NOT a benefit of storing SQL code in the database? Choice 1 It enhances security. Choice 2 It is compiled at run-time. (Check) Choice 3 It may be accessed by multiple applications. Choice 4 It is centralized. Choice 5 It improves performance. What two operations are combined by the EXECUTE IMMEDIATE command? Choice 1 EXECUTE and COMMIT Choice 2 PREPARE and EXECUTE Choice 3 EXECUTE and EXPLAIN Choice 4 BIND and RUN Choice 5 CREATE and PREPARE

INTEGER Choice 4 FLOAT Choice 5 DECIMAL In a stored procedure, what phrase do you add to a cursor declaration in order to allow the calling program access to the cursor's result set? Choice 1 WITH UR Choice 2 FOR RETURN Choice 3 WITH RETURN Choice 4 PASS TO CLIENT Choice 5 RETURN TO CALLER Which one of the following SQL statements releases all locks? Choice 1 RELEASE (CHECK) Choice 2 DELETE Choice 3 COMMIT Choice 4 DEALLOCATE Choice 5 UNLOCK SELECT e.name, MAX(t.logindate) LastLogin FROM LoginAuditTrail t JOIN employee e ON e.emp_id = t.emp_id WHERE e.type = 'SALARY' Considering the query shown above, which one of the following statements do you use to complete the query and sort the results by LastLogin? Choice 1 GROUP BY e.name, MAX(t.logindate) Choice 2 GROUP BY e.name ORDER BY e.name, MAX(t.logindate) Choice 3 GROUP BY e.name ORDER BY MAX(t.logindate) Choice 4 GROUP BY MAX(t.logindate) Choice 5 GROUP BY e.name

ALTER TABLE EMPLOYEE ADD CONSTRAINT check_title CHECK (TITLE IN ('Developer', 'Manager')); What is the effect of adding the above constraint to the Employee table? Choice 1 Existing records with TITLE values not in the list are deleted. Choice 2 Any new records must have a TITLE of "Developer" or "Manager". (CHECK) Choice 3 Records inserted with TITLE values other than those in the list are logged for review. Choice 4 For new records, the TITLE value is added by the system. Choice 5 Records inserted with TITLE values of "Developer" or "Manager" are logged for review. What data type do you use when defining a sequence number for your table? Choice 1 CHAR Choice 2 DOUBLE Choice 3

How do you specify that a cursor only returns 10 rows? Choice 1 OPTIMIZE FOR 10 ROWS Choice 2 STOPAFT = 10 Choice 3 FETCH FIRST 10 ROWS ONLY Choice 4 LIMIT TO 10 ROWS Choice 5 ROWLIMIT = 10 SELECT * FROM employees What do you add to the sample code above in order to retrieve all records from the employees table in which the last_name column begins with the letters SM? Choice 1 WHERE last_name IN ('S','M') Choice 2 WHERE last_name IS 'SM*' Choice 3 WHERE last_name LIKE 'SM%' Choice 4 WHERE last_name = 'SM' Choice 5 WHERE last_name[1 TO 2] = 'SM' POSSTR( var_name, '.') Based on the sample code above, what value does the POSSTR function return? Choice 1 The position of the first occurrence of a period in var_name Choice 2 The number of periods found in var_name Choice 3 The contents of var_name without any embedded periods Choice 4 Characters in var_name that occur after a period Choice 5 Characters in var_name that occur before a period Where are access plans that are created by dynamic SQL statements kept for reuse? Choice 1 In the dynamic look-aside area Choice 2 In the bufferpools Choice 3 In the tablespace cache Choice 4 In the dynamic statement cache Choice 5

In the package cache Which one of the following may cause records to be deleted? Choice 1 Column-check constraints Choice 2 Referential integrity constraints (CHECK) Choice 3 Primary key constraints Choice 4 User-defined data types Choice 5 Table-check constraints What are the valid data types for date/time values? Choice 1 DATE, TIME, TIMESTAMP Choice 2 DATE, TIME, DATETIME Choice 3 DATE, INTERVAL, TIME Choice 4 DATETIME, TIME, DATE Choice 5 DATEPART, INTERVAL, TIMEVAL What clause do you need to include in a cursor declaration if you plan to modify the data returned? Choice 1 FOR READ ONLY Choice 2 WITH LOCKS Choice 3 FOR UPDATE OF Choice 4 WITH UPDATE Choice 5 FOR MODIFY OF When inserting data to a table, what do you need to specify? Choice 1 Values for all NOT NULL columns, unless they are defined WITH DEFAULT Choice 2 Values for all indexed columns Choice 3 Values and data types for each column Choice 4 Values for all NOT NULL columns Choice 5 Values for all columns in the table SELECT a.type, a.description, b.type, b.description FROM a

Which statement do you add to the above query to return all types and descriptions from both tables, regardless of whether or not they have a corresponding value in the other table?

A SELECT statement cannot list regular columns after aggregate functions. Choice 5 An ORDER BY clause cannot refer to an aggregate function in the SELECT list. Table Definition

Choice 1 INCLUSIVE JOIN b ON a.type = b.type Choice 2 JOIN ALL b ON a.type = b.type Choice 3 RIGHT OUTER JOIN b ON a.type = b.type Choice 4 LEFT OUTER JOIN b ON a.type = b.type Choice 5 FULL OUTER JOIN b ON a.type = b.type Which one of the following is NOT an advantage of storing dates using the DATE data type?

Choice 1 A DATE takes less physical storage space. Choice 2 You can perform mathematical functions against a DATE. Choice 3 DATE values can be set to NULL; CHAR cannot. Choice 4 Using a DATE ensures that the value stored is a valid date. Choice 5 The value of a DATE can be displayed in multiple formats. SELECT a, AVG(b), c FROM vtable WHERE a > c GROUP BY a, c ORDER BY 2 DESC, 4 Why does the above query produce an error? Choice 1 Once the ORDER BY clause uses the keyword DESC, all columns in the ORDER BY clause must use either ASC or DESC. Choice 2 The GROUP BY clause must contain all elements of the SELECT list (regular columns as well as aggregate functions). Choice 3 The ORDER BY clause contains a select list number that is out of range. Choice 4

Referring to the above, how do you delete all of the PETS records who are without a BIRTH_DATE value? Choice 1 REMOVE FROM PETS WHERE BIRTH_DATE = NULL Choice 2 DELETE FROM PETS WHERE BIRTH_DATE = '' Choice 3 DELETE FROM PETS WHERE NOT VALID DATE(BIRTH_DATE) Choice 4 DELETE FROM PETS WHERE BIRTH_DATE IS NULL Choice 5 DELETE FROM PETS WHERE BIRTH_DATE = NULL CREATE PROCEDURE test_proc( IN p_emp_id CHAR(09) ,OUT p_sqlstate CHAR(05)) LANGUAGE SQL BEGIN DECLARE SQLSTATE CHAR(05) DEFAULT '00000'; DECLARE EXIT HANDLER FOR SQLEXCEPTION SET p_sqlstate = SQLSTATE; -- body of procedure END Which one of the following statements do you add to the above procedure to set the SQLSTATE and return it to the calling program when no p_emp_id is passed?

Choice 1 IF p_emp_id IS NULL then SIGNAL SQLSTATE '70001' SET MESSAGE_TEXT = 'Emp ID is required';

Choice 2 IF p_emp_id IS NULL then RETURN SQLSTATE '70001' SET MESSAGE_TEXT = 'Emp ID is required';

Choice 3 IF p_emp_id IS NULL then RESET SQLSTATE '70001' SET MESSAGE_TEXT = 'Emp ID is required';

It writes the number of employees to the history log file each time a new person is added to the employee table. SELECT * FROM employees WHERE NUM_ DEPEND BETWEEN 3 AND 5 Which employee records does the above query return? Choice 1 Employees with either three or five dependents Choice 2 Employees with either three or four dependents Choice 3 Employees with either four or five dependents Choice 4 Employees with three, four, or five dependents Choice 5 Employees with exactly four dependents SELECT first_name, last_name, ssn, years_of_service FROM employees Which ORDER BY clause, added to the code above, sorts the rows by years of service with those who have been with the company longest listed first?

Choice 4 IF p_emp_id IS NULL then ERROR SQLSTATE '70001' SET MESSAGE_TEXT = 'Emp ID is required'; Choice 5 IF p_emp_id IS NULL then VALUE SQLSTATE '70001' SET MESSAGE_TEXT = 'Emp ID is required'; If your program has performed several inserts or updates and then fails before you issue a COMMIT, what is the result? Choice 1 The DB2 system fails. Choice 2 It depends on the transaction's isolation level. Choice 3 The current unit of work is committed. Choice 4 The failure is logged and the transaction resumes from the point of failure. Choice 5 The current unit of work is rolled back. CREATE TRIGGER NEW_HIRED AFTER INSERT ON EMPLOYEE FOR EACH ROW MODE DB2SQL UPDATE COMPANY_STATS SET NUM_EMP = NUM_EMP + 1; Assume the table COMPANY_STATS has a single row.

Based on the sample code above, what is the function of this trigger? Choice 1 It adds a new record to the COMPANY_STATS table each time a new person is added to the employee table. Choice 2 It increases the number of employees each time a new person is added to the employee table. Choice 3 It inserts a row into employee_audit table. Choice 4 It decreases the number of employees each time a person is deleted from the employee table. Choice 5

Choice 1 ORDER BY years_of_service DESC Choice 2 ORDER BY 'years_of_service' Choice 3 ORDER BY 'years_of_service' DESC Choice 4 ORDER BY years_of_service ASC Choice 5 ORDER years_of_service DESC At what three levels can you specify isolation levels? Choice 1 Program, User, and Database Choice 2 Statement, Connection/Session, and Unit of Work Choice 3 Database, Table, and Row Choice 4 Connection/Session, Application, and Statement Choice 5 Bind, Application, and Statement

Which one of the following SQL statements can you use against the system catalog tables? Choice 1 INSERT Choice 2 SELECT Choice 3 DELETE Choice 4 LOAD Choice 5 UPDATE Why do you use SQLSTATE instead of SQLCODE for error handling?

A RAISE_ERROR command Choice 5 A condition HANDLER CREATE PROCEDURE test_proc( IN p_emp_id CHAR(9) ,OUT p_error_code CHAR (5)) LANGUAGE SQL BEGIN DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SELECT SQLCODE, SQLSTATE INTO out_sqlcode, out_sqlstate FROM SYSIBM.SYSDUMMY1; -- procedure body and logic END

Choice 1 SQLCODE values are not available in stored procedures. Choice 2 SQLCODE requires additional overhead to process. Choice 3 SQLSTATE uses less memory. Choice 4 SQLSTATE values are standard across vendors and platforms. Choice 5 SQLSTATE provides a smaller number of codes to check. Which one of the following do you use to place the value of today's date into the variable "program_date"? Choice 1 set program_date = run_date Choice 2 set program_date = current timestamp Choice 3 set program_date = current date Choice 4 set program_date = date(today) Choice 5 set program_date = now() What structure do you define for error processing in an SQL stored procedure?

What is the result of the above code if the procedure test_proc encounters an error?

Choice 1 The procedure continues at the statement following the error; the values for SQLCODE and SQLSTATE are returned to the calling program through out_sqlcode and out_sqlstate.

Choice 2 The procedure is terminated; the values for SQLCODE and SQLSTATE are returned to the calling program.

Choice 3 The procedure continues at the next BEGIN statement following the error; the values for SQLCODE and SQLSTATE are lost. Choice 4 The procedure continues at the statement following the error; the values for out_sqlcode and out_sqlstate are available for processing. Choice 5 The procedure is terminated; the values for SQLCODE and SQLSTATE are lost.

Choice 1 ROLLBACK sections Choice 2 A WHENEVER statement Choice 3 An ON_ERROR section Choice 4

When are page or row locks acquired? Choice 1 When an SQL statement is executed Choice 2 When the user logs in

Choice 3 When the program is bound Choice 4 When the program is compiled Choice 5 When the program is executed When new employees are hired, their information is added to the EMPLOYEE table. Any data records in the APPLICANT table must be removed when the employee is hired. In the above scenario, what database object do you define in order to automate the APPLICANT deletion? Choice 1 An update trigger on EMPLOYEE Choice 2 A delete trigger on APPLICANT Choice 3 A table constraint on EMPLOYEE Choice 4 A User Defined Function (UDF) Choice 5 An insert trigger on EMPLOYEE

Referring to the above sample code, which one of the following lines returns an error? Choice 1 Line 1 Choice 2 Line 2 Choice 3 Line 3 Choice 4 Line 4 Choice 5 Line 5 CREATE PROCEDURE get_emp_status (IN p_emp_id CHAR(9), INOUT p_status_dt DATE, OUT p_emp_status) Procedure get_emp_status is called with an employee ID and a request date. It provides the status as of that request date, and also the date the employee started that status.

How do you call the above procedure and use the information returned? EXEC SQL DECLARE C1 CURSOR FOR SELECT * FROM EMPLOYEE FOR UPDATE OF JOB; EXEC SQL OPEN C1; EXEC SQL FETCH C1 INTO ... ; Based on the sample code above, how do you change the JOB of a certain employee to a new JOB? Choice 1 EXEC SQL UPDATE EMPLOYEE SET JOB = :newjob FROM C1; Choice 2 EXEC SQL UPDATE EMPLOYEE SET JOB = :newjob FROM CURRENT OF C1; Choice 3 EXEC SQL UPDATE EMPLOYEE SET JOB = :newjob WHERE CURRENT OF C1; Choice 4 EXEC SQL UPDATE C1 SET JOB = :newjob; Choice 5 EXEC SQL UPDATE C1 SET JOB = :newjob WHERE CURRENT OF C1; 1 2 3 4 5 SELECT * FROM classes c, students s WHERE c.st_id = s.id AND LEN(s.name) > c.st_id ORDER BY c.* Choice 1 Populate p_emp_status and p_status_dt, execute the procedure, and use the values from p_status_dt and p_emp_id.

Choice 2 Populate p_emp_id and p_status_dt, execute the procedure, and use the values from p_status_dt and p_emp_status.

Choice 3 Populate p_emp_id and p_status_dt, execute the procedure, and use only the value from p_emp_status.

Choice 4 Populate the three variables and execute the procedure.

Choice 5 Populate p_emp_id, execute the procedure, and use the values from p_status_dt and p_emp_status. What is a unit of work? Choice 1

A sequence of operations within multiple application processes Choice 2 An application program Choice 3 An application Choice 4 An unrecoverable sequence of operations within an application process Choice 5 A recoverable sequence of operations within an application process

Setting the new value of a column to the average for the table without using a subquery Choice 3 Deleting a column from a table--changing the number of columns in a table from four to three, for example Choice 4 Changing the datatype of a particular field Choice 5 Inserting new rows into a table if they do not already exist Which one of the following statements do you use to terminate a unit of work and to remove changes that were made by that unit of work? Choice 1 CLOSE Choice 2 ROLLBACK Choice 3 DEALLOCATE Choice 4 SELECT Choice 5 COMMIT

SELECT DEPT_ID, DEPT_NAME, VALUE(MGR_ID, 'ABSENT') FROM DEPT OPTIMIZE FOR 1 ROWS; What does the above code return if the DEPT table contains 100 rows? Choice 1 All rows containing non-NULL MGR_IDs Choice 2 Execution failure due to invalid syntax Choice 3 1 row random containing 3 columns, showing ABSENT when MGR_ID is null Choice 4 100 rows containing 3 columns, showing ABSENT when MGR_ID is null Choice 5 100 rows with the 3 column values, displaying NULL values Which one of the following is a valid DB2 TIMESTAMP? Choice 1 '1776-7-4-12.00.00.000000' Choice 2 '1961-09-05-22.30.25.423578' Choice 3 '2007-09-31-12.00.00.000000' Choice 4 '1989/08/23/02:22:00.000000' Choice 5 '1985-07-13-19.62.01.123456'

Which isolation levels prevent a transaction from having different results if a query is executed multiple times? Choice 1 RR, RS Choice 2 CS, RR Choice 3 RS, CS Choice 4 UR, RR Choice 5 UR, CS What function do you use to show the access path and indexes that the optimizer has chosen for a statement?

Which one of the following is possible using the UPDATE statement? Choice 1 Updating a column in one table with data from another table Choice 2

Choice 1 ACCESS Choice 2 CHECKPATH Choice 3 OPTIMIZE Choice 4 EVALUATE Choice 5 EXPLAIN

If you want a column to be part of the result set, after which SQL keyword does it belong? Choice 1 GROUP BY Choice 2 HAVING Choice 3 SELECT Choice 4 SET Choice 5 WHERE SELECT DATE('2008-05-31') - 1 MONTH What is the result of the above query? Choice 1 2008-05-30 Choice 2 2008-04-30 Choice 3 The query is not valid and causes an error. Choice 4 2008-05-01 Choice 5 2008-04-31 What SQL structure allows you to specify the columns and values for an INSERT statement in a different order than the columns appear in the table? Choice 1 The SET statement Choice 2 The ALTER TABLE statement Choice 3 The column list, as in "INSERT INTO employees (emp_id, last_name, first_name)" (CHECK) Choice 4 The values list, as in "INSERT INTO employees VALUES (24, 'Smith', 'John')" Choice 5 The ORDER BY clause Function Declaration CREATE FUNCTION LEAP_YEAR_CHECK(in_date DATE) RETURNS INTEGER BEGIN IF MOD(in_date, 4) = 0 THEN return 1; ELSE return 0; END IF; END

Referring to the above code, what do you need to pass to the function when you call it? Choice 1 A value for the year to check Choice 2 The Work Load Manager (WLM) to execute under Choice 3 A valid date (CHECK) Choice 4 The date format for your system Choice 5 An integer variable to return the result

CREATE PROCEDURE get_account_info(acct_no INTEGER) LANGUAGE SQL DYNAMIC RESULT SETS 3

In the above stored procedure definition, what is the meaning of the phrase DYNAMIC RESULT SETS 3? Choice 1 There are three BEGIN/END blocks in the procedure. Choice 2 Three parameters are passed back from the procedure. Choice 3 The procedure requires additional memory. Choice 4 The procedure returns three result sets. Choice 5 The procedure uses three cursors. What statement do you use to return the last day of the current month? Choice 1 SUBSTR(DATEADD(CURRENT DATE,1 MONTH),1,8) CONCAT '01' - 1 DAY Choice 2 DATE(SUBSTR(CHAR(CURRENT DATE),1,8) CONCAT '01') + 1 MONTH Choice 3 CURRENT DATE + 30 DAYS Choice 4 DATE(MONTH(CURRENT DATE) + 1), DAY(01)) Choice 5 DATE(SUBSTR(CHAR(CURRENT DATE + 1 MONTH),1,8) CONCAT '01') - 1 DAY What is the advantage of creating a non-fenced stored procedure instead of a fenced stored procedure? Choice 1

It increases connect time. Choice 2 It decreases the amount of disk space required on the server. Choice 3 It decreases the amount of memory required by the application. Choice 4 It increases database security. Choice 5 It increases application performance. CREATE TABLE EMPLOYEE ( SSN CHAR(11) NOT NULL WITH DEFAULT, LNAME CHAR(30) NOT NULL, FNAME CHAR(30) NOT NULL, SALARY DECIMAL(9,2) NOT NULL, HIRE_DT TIMESTAMP, AGE INTEGER ); If you use a cursor to select information from the employee table above, what must you associate with any host variable used for the AGE field? Choice 1 Local variable Choice 2 Temporary variable Choice 3 Static variable Choice 4 Indicator variable Choice 5 Global variable What do you add to a cursor declaration to keep it from being closed by a COMMIT? Choice 1 WITH RETURN Choice 2 HOLD ON COMMIT Choice 3 KEEP OPEN Choice 4 HOLD OPEN Choice 5 WITH HOLD Which isolation level is the most restrictive? Choice 1 RR (Repeatable Read) Choice 2 CR (Consistent Read) Choice 3 RS (Read Stability) Choice 4

UR (Uncommitted Read) Choice 5 CS (Cursor Stability) CREATE SEQUENCE order_num_seq AS INTEGER START WITH 10 INCREMENT BY 10 Considering the sequence object defined above, how do you retrieve the next order_num_seq? Choice 1 order_num_seq + 10 Choice 2 NEXTVAL(order_num_seq) Choice 3 NEXT SEQUENCE for order_num_seq (CHECK) (none of the options are correct) Actual Answer is NEXT VALUE FOR order_num_seq Choice 4 NEXT(order_num_seq) Choice 5 order_num_seq.NEXTVAL SELECT CHAR(CURRENT DATE, USA) FROM SYSIBM.SYSDUMMY1

What date format are you requesting by specifying "USA" in the above query? Choice 1 yyyy-mm-dd Choice 2 dd.mm.yyyy Choice 3 mm/dd/yyyy Choice 4 yyyy-dd-mm Choice 5 mm-dd-yyyy You wish to handle specific conditions by defining SQLSTATE condition codes within your program. Referring to the above scenario, which one of the following is a valid user-defined SQLSTATE? Choice 1 00600 Choice 2 01000 Choice 3 06000 Choice 4 99001 Choice 5

A1SQL What kind of access do you acquire with a U lock and what access is allowed to others while you hold that lock?

000-000-0000 Choice 5 NULL

Choice 1 Read with intent to update Others have no access Choice 2 Read only Others may update Choice 3 Update access Others may update Choice 4 Read with intent to update Others may read only Choice 5 Update access Others have no access Which command do you use to retrieve only the date portion of timestamp field :hv_tmstp?

DECLARE EMP_CURSOR cursor for SELECT EMP_ID INTO :emp-id FROM EMPLOYEE FOR READ ONLY Why is the above cursor NOT valid? Choice 1 The OPEN WITH clause is missing. Choice 2 FOR READ ONLY cannot be included in a cursor declaration. Choice 3 The data type of emp-id is not specified. Choice 4 Host variables are used in the cursor FETCH, not the declaration. Choice 5 Special characters may not be included in cursor names. Which one of the following do you use to find the UTC (Coordinated Universal Time, also known as GMT) for the current date and time? Choice 1 TIMESTAMP(CURRENT DATE , CURRENT TIMESTAMP - CURRENT TIMEZONE) Choice 2 CURRENT TIMESTAMP + CURRENT TIMEZONE Choice 3 NOW(UTC) Choice 4 CURRENT TIMESTAMP - CURRENT TIMEZONE Choice 5 TIMESTAMP(CURRENT TIMESTAMP, UTC) When you code a SELECT statement within the FROM clause of another SQL statement, what kind of expression are you using? Choice 1 Nested table Choice 2 Mixed table Choice 3 Transient table Choice 4 Temporary table Choice 5 Interior table

Choice 1 LTRIM(:hv_tmstp, 10) Choice 2 LEFT(:hv_tmstp) Choice 3 DATEONLY(:hv_tmstp) Choice 4 EXTRACT(:hv_tmstp, DATE) Choice 5 DATE(:hv_tmstp)

CREATE TABLE employee (ID SMALLINT NOT NULL PRIMARY KEY, SSN CHAR(11) NOT NULL UNIQUE, NAME VARCHAR(35) NOT NULL, ADDRESS VARCHAR(255) NOT NULL, PHONE CHAR(12) , HIRE_DT DATE NOT NULL WITH DEFAULT) Based on the sample code above, what is the default value of PHONE when you insert a record into the employee table? Choice 1 0 Choice 2 1 space Choice 3 12 spaces Choice 4

The ORDER and ORDER_HISTORY tables are defined with the same data structure. Expired order records are removed from the ORDER table and moved to the ORDER_HISTORY table every month. What keyword do you use to return records from both of the above tables into a single result set? Choice 1 COALESCE Choice 2 INNER JOIN Choice 3 UNION Choice 4 MERGE Choice 5 JOIN What statement is required before you EXECUTE a dynamic SQL statement? Choice 1 EXPLAIN Choice 2 PREPARE Choice 3 OPTIMIZE Choice 4 CHECK Choice 5 BIND

UPDATE books SET sales_1999 > (SELECT SUM(qty * price) FROM sales WHERE sales.book_id = books.id AND sales.date BETWEEN '01/01/1999' AND '12/31/1999') Why does the above query produce an error? Choice 1 You cannot use a subquery in the SET clause of an UPDATE statement. Choice 2 There is no reference in the subquery to the table from the UPDATE statement. Choice 3 The BETWEEN keyword cannot be used with character or date fields. Choice 4 You cannot use a relational operator to set a value. Choice 5 You cannot use an arithmetic operator within the SUM() function.

What SQLCODE value indicates that the user does NOT have sufficient authorization to perform a requested operation? Choice 1 -911 Choice 2 -811 Choice 3 -803 Choice 4 -551 Choice 5 +100 Referring to the above, how do you delete all of the PETS records who are without a BIRTH_DATE value? Choice 1 DELETE FROM PETS WHERE BIRTH_DATE = NULL Choice 2 DELETE FROM PETS WHERE BIRTH_DATE IS NULL Choice 3 DELETE FROM PETS WHERE NOT VALID DATE(BIRTH_DATE) Choice 4 REMOVE FROM PETS WHERE BIRTH_DATE = NULL Choice 5 DELETE FROM PETS

Referring to the above, what statement do you use to change the BIRTH_DATE value for a dog named Spike to NULL? Choice 1 UPDATE PETS SETNULL(BIRTH_DATE) WHERE PET_NAME = 'Spike' Choice 2 UPDATE PETS SET PET_NAME = NULL WHERE_BIRTH_DATE IS NULL Choice 3 UPDATE PETS SET BIRTH_DATE = NULL WHERE PET_NAME = 'Spike' Choice 4 UPDATE PETS SET BIRTH_DATE to NULL WHERE PET_NAME = 'Spike' Choice 5 UPDATE PETS SET BIRTH_DATE = 'NULL' WHERE PET_NAME = 'Spike'

WHERE BIRTH_DATE = '' Which SQL statement does NOT invoke a sort? Choice 1 UNION ALL Choice 2 SELECT DISTINCT Choice 3 UNION Choice 4 GROUP BY Choice 5 ORDER BY Expenses dept type dollar ---- ---- ---------A P 100 A D 0 A S 50 A P 100 B P NULL B P 10 B D 100 B S 400 C D 320 C S 100 select 'High Expenses', count(*) from expenses where dollar > 100 union select 'Low Expenses', count(*) from expenses where dollar <= 100 union select 'Unknown Expenses', count(*) from expenses where dollar IS NULL order by 1 Referring to the Expenses table in the scenario above, what is the result of the query? Choice 1 High Expenses 7 Low Expenses 2 Unknown Expenses 1 Choice 2 High Expenses 2 Low Expenses 7 Unknown Expenses 1 Choice 3 Unknown Expenses 2 Low Expenses 7 High Expenses 1 Choice 4 High Expenses 1 Low Expenses 7 Unknown Expenses 2 Choice 5

Unknown Expenses 1 Low Expenses 7 High Expenses 2 What do you use to separate multiple criteria in an SQL WHERE clause? Choice 1 Commas Choice 2 Periods Choice 3 Semi-colon Choice 4 The keywords AND or OR Choice 5 The keyword FROM What type of database object do you create if you want to reduce network traffic? Choice 1 Stored procedure Choice 2 User-defined function Choice 3 Constraint Choice 4 View Choice 5 Trigger

What is the difference between the DAYOFWEEK and DAYNAME functions? Choice 1 DAYOFWEEK returns an integer between 1 and 7; DAYNAME returns a character string. Choice 2 There is no difference; either will produce the same result. Choice 3 DAYNAME requires a DATE argument; DAYOFWEEK requires a number in format YYYYDDD. Choice 4 DAYNAME returns an integer between 1 and 7; DAYOFWEEK returns a character string. Choice 5 DAYOFWEEK cannot be used in stored procedures; DAYNAME can be used in procedures and functions.

Why do you define a column as VARCHAR? Choice 1 Column values may exceed 32,672 characters. Choice 2 To allow the column to contain both character and numeric data Choice 3 To save storage when column values vary greatly in string length Choice 4 So that you do not have to pad inserted values with trailing spaces Choice 5 To allow index usage What type of index determines the physical order of stored data records? Choice 1 Partitioning Choice 2 Primary Key Choice 3 Sequencing Choice 4 Ordering Choice 5 Clustering Which one of the following is a valid INSERT statement in ANSI SQL? Choice 1 INSERT INTO students (id, first_name, last_name) VALUES (100, 'Kim', 'Matheson') Choice 2 INSERT INTO students SELECT VALUES (95, 'Bill', 'Enzo') Choice 3 INSERT INTO students (id, first_name, last_name) SELECT id, first_name FROM new_students WHERE last_name IS NULL Choice 4 INSERT_REPLACE IN students (id, first_name, last_name) VALUES (100, 'Kim', 'Matheson') Choice 5 INSERT INTO students (id, first_name, last_name) (118, 'Ellen', 'Moran') Sample Code 1 SELECT a.field1, b.field2, c.field3, d.field4 2 FROM atable a, atable b, ctable c, dtable d 3 ? 4 ORDER BY 1

What is the minimum number of joins that you must specify on line 3 in the sample code above in order to properly link the tables? Choice 1 1 Choice 2 2 Choice 3 3 Choice 4 4 Choice 5 5 What is the difference between a UNION statement and a UNION ALL statement? Choice 1 A UNION statement cannot be used with aggregate functions; a UNION ALL statement can be used with aggregate functions. Choice 2 A UNION statement can only combine queries that have parallel fields in the SELECT list; a UNION ALL statement can combine queries with differing SELECT list structures. Choice 3 A UNION statement returns the rows common between the result sets generated by each query; a UNION ALL returns all rows retrieved by both queries. Choice 4 A UNION statement eliminates duplicate rows; a UNION ALL statement includes duplicate rows. Choice 5 A UNION statement can be used to combine any number of queries; a UNION ALL statement can be used to combine a maximum of two queries.

What type of variable do you define to hold an SQLCODE value? Choice 1 DECIMAL(5,0) Choice 2 CHAR(3) Choice 3 VARCHAR(5) Choice 4 CHAR(5) Choice 5 INTEGER A system catalog table contains which one of the following? Choice 1

Open Database Connectivity (ODBC) driver information Choice 2 DB2 environment settings information Choice 3 DB2 instance information Choice 4 Database tuning parameters information Choice 5 Database definition information Which one of the following statements regarding query optimization is true? Choice 1 The performance of a query referencing a particular table is improved if there are two or more indexes on that table that share one or more columns. Choice 2 It is generally more useful to place an index on a field that contains little variation, such as gender, than one that contains significant variation, such as a social security number. Choice 3 Adding more columns to a multi-column index improves the performance of a query that refers to some of the columns in the index. Choice 4 The components of the WHERE clause and their associated indexes have the most effect on the performance of a query. Choice 5 The more indexes on a table, the faster a query that accesses that table will run. Which one of the following is true about sorting SQL results sets? Choice 1 Including a subquery in an ORDER BY clause is allowed, provided that the subquery returns only one numeric value and the value corresponds to a column in the select list. Choice 2 If the ORDER BY column contains NULL values, those records appear at the end of the results set. Choice 3 The ORDER BY clause should be placed after a GROUP BY clause, if present, but before a HAVING clause, if present. Choice 4 The keyword ASC, which is optional when sorting by character fields, must be used after a column name that contains numeric data such as ORDER BY salary ASC. Choice 5 Mixing column names and select list numbers (such as ORDER BY product, 2, price, 4) is allowed.

Which one of the following statements does NOT allow use of a matching index access? Choice 1 WHERE BIRTH_YR IN (00, 99) Choice 2 WHERE BIRTH_YR BETWEEN 00 AND 99 Choice 3 WHERE BIRTH_YR <> 70 Choice 4 WHERE T1.BIRTH_YR = T2.BIRTH_YR Choice 5 WHERE BIRTH_YR = 70 CREATE PROCEDURE emp_address(IN p_emp_id CHAR(09) ,OUT p_emp_street CHAR(20) ,OUT p_emp_city_st CHAR(20)) LANGUAGE SQL SPECIFIC emp_address BEGIN DECLARE v_emp_street, v_emp_city_st as CHAR(20); SELECT EMP_STREET ,EMP_CITY || ', ' || EMP_STATE INTO v_emp_street ,v_emp_city_st FROM EMPLOYEE WHERE EMP_ID = p_emp_id; set p_emp_street = v_emp_street; END What line of code do you need to add to the above procedure so that it returns all the requested data? Choice 1 RETURN v_emp_street, v_emp_city_st; Choice 2 DECLARE p_emp_city_st as CHAR (20); Choice 3 set p_emp_city_st = v_emp_city_st; Choice 4 RETURN p_emp_street, p_emp_city_st; Choice 5 DYNAMIC RESULT SETS 1 Which one of the following is NOT a valid column function? Choice 1 DATETIME Choice 2 SUBSTR Choice 3 DAYOFWEEK

Choice 4 CHAR Choice 5 DECIMAL SELECT * FROM SOME_TABLE What phrase do you add to the above query to instruct DB2 to return all rows, even if they are locked by another transaction? Choice 1 WITH RR Choice 2 READ ALL Choice 3 LOCK TABLE Choice 4 WITH LOCKS Choice 5 WITH UR

NOT EXISTS can return multiple results. Choice 3 NOT IN is not supported on all platforms. Choice 4 NOT IN is limited to character values. Choice 5 NOT IN requires that the subquery result set be materialized.

What three steps do you follow to return a cursor's result set from a stored procedure? Choice 1 Specify DYNAMIC RESULT SETS, declare the cursor WITH RETURN, and open the cursor in the procedure. Choice 2 Specify FOR RESULT SET, declare the cursor WITH RETURN, and open the cursor in the procedure. Choice 3 Specify FENCED, declare the cursor WITH HOLD, and open the cursor in the procedure. Choice 4 Declare the cursor WITH RETURN, PREPARE the cursor, and use the RETURN command to pass the cursor name to the calling program. Choice 5 Specify DYNAMIC RESULT SETS, declare the cursor WITH RETURN, and return the cursor name in an OUT parameter.

DELETE FROM doctors d, physicians p WHERE d.doc_id = p.phys_id AND d.house_calls = 'N' AND p.fee > (SELECT MAX(gnp) FROM countries WHERE world = 3) What happens to the doctors and physicians tables when you execute the sample code above? Choice 1 Nothing happens to either table because the use of a subquery in the WHERE clause of the DELETE statement causes an error. Choice 2 The corresponding rows are deleted from the doctors table because it is listed first, but the physicians table remains unaffected. Choice 3 Nothing happens to either table because the inclusion of more than one table in the DELETE statement causes an error. Choice 4 The corresponding rows are deleted from both the doctors table and the physicians table. Choice 5 All rows from both tables are deleted because of an improper join between doctors and physicians.

Which SQLCODE values correspond to SQLSTATE 22007, which indicates invalid date or time values? Choice 1 -803 and -805 Choice 2 -801 and -811 Choice 3 -501 and -185 Choice 4 -188 and -189 Choice 5 -180 and -181

Why do you use NOT EXISTS rather than NOT IN when coding a subquery using negation logic? Choice 1 NOT EXISTS allows use of an index. Choice 2

Which isolation level prevents "phantom reads", in which new rows inserted into a table cause subsequent reads to have different results? Choice 1 CS Choice 2 RS Choice 3 CR

Choice 4 RR Choice 5 UR What SQLCODE value indicates that an embedded SELECT statement returns multiple rows, requiring the use of a cursor? Choice 1 -911 Choice 2 -811 Choice 3 -803 Choice 4 -551 Choice 5 +100

Choice 1 None, the columns in the SELECTs do not match, which causes an error. Choice 2 None, WHERE cannot intersect. Choice 3 None, ORDER BY in the first SELECT causes an error. Choice 4 Three rows Choice 5 Five rows An update program is locking enough data to cause lock escalation, but adding COMMIT statements is not an acceptable option. How do you prevent the overhead of lock escalation in this situation? Choice 1 Add the SET MAXLOCKS instruction to your program. Choice 2 Add the SET LOCKESC= -1 instruction to your program. Choice 3 Ensure that the program uses Repeatable Read (RR) isolation. Choice 4 Change the order in which your program accesses the data. Choice 5 Add the LOCK TABLE instruction to the program.

What is the only special character you use in a column name? Choice 1 Underscore Choice 2 Hyphen Choice 3 Pound sign Choice 4 Percent sign Choice 5 Dollar sign

ACCOUNT acc_no acc_type amount --------- ---------- --------10 c 356.12 31 m 1387.64 25 c 12500.00 22 m 40356.15 61 c 12500.00 SELECT acc_type, amount, 'small' as category1 FROM ACCOUNT WHERE amount <= 10000 ORDER BY acc_type, amount UNION SELECT acc_type, amount, 'big' as category2 FROM ACCOUNT WHERE amount >= 10000 ORDER BY amount,acc_type Referring to the above table, how many rows does the query return?

When handling error conditions, programs may implement "retry" logic to attempt the operation again before failing. Which one of the following error conditions justifies retry logic as described above? Choice 1 Deadlock or timeout Choice 2 Value incompatible with column's data type Choice 3 Duplicate key violation Choice 4 Insufficient authorization Choice 5 Row not found

Вам также может понравиться