66. | Given the following two tables:
NAMES ----------------------------- NAME NUMBER ---------- ------- Wayne Gretzky 99 Jaromir Jagr 68 Bobby Orr 4 Bobby Hull 23 Mario Lemieux 66 POINTS ----------------------------- NAME POINTS ---------- ------ Wayne Gretzky 244 Bobby Orr 129 Brett Hull 121 Mario Lemieux 189 Joe Sakic 94 How many rows would be returned using the following statement?
SELECT name FROM names, points
|
| ||||||||||
67. | Given the following CREATE TABLE statement:
CREATE TABLE EMPLOYEE (EMPNO CHAR(3) NOT NULL, FIRSTNAME CHAR(20) NOT NULL, MIDINIT CHAR(1), LASTNAME CHAR(20) NOT NULL, SALARY DECIMAL(10, 2)) Which of the following will retrieve the rows that have a missing value in the MIDINIT column?
|
| ||||||||||
68. | Given the following two tables:
TAB1 ---------------------- COL_1 COL_2 ----- ----- A 10 B 12 C 14 TAB2 ---------------------- COL_A COL_B ----- ----- A 21 C 23 D 25 Assuming the following results are desired:
COL_1 COL_2 COL_A COL_B A 10 A 21 B 12 - - C 14 C 23 - - D 25 Which of the following joins will produce the desired results?
|
| ||||||||||
69. | If the following SQL statements are executed in the order shown:
CREATE TABLE table1 (c1 INTEGER, c2 INTEGER); INSERT INTO table1 VALUES (123, 456); UPDATE table1 SET c1 = NULL; What will be the result of the following statement?
SELECT * FROM table1;
|
| ||||||||||
70. | Given the following table:
TAB1 COL1 COL2 ----- ----- A 10 B 20 C 30 A 10 D 40 C 30 Assuming the following results are desired:
TAB1 COL1 COL2 ----- ----- A 10 B 20 C 30 D 40 Which of the following statements will produce the desired results?
|
| ||||||||||
71. | Assuming table TAB1 contains 100 rows, which of the following queries will return only half of the rows available?
|
| ||||||||||
72. | Given the following two tables:
EMPLOYEE ID NAME DEPTID -- ---------------- --- 01 Mick Jagger 10 02 Keith Richards 20 03 Ronnie Wood 20 04 Charlie Watts 20 05 Bill Wyman 30 06 Brian Jones - DEPARTMENT ID DEPTNAME -- ------------------ 10 Executive Staff 20 Sales 30 Marketing 40 Engineering 50 Human Resources Which two of the following queries will display the employee name and department name for all employees that are in Sales?
|
| ||||||||||
73. | Given the following queries:
SELECT c1 FROM tab1; SELECT c1 FROM tab2; Which of the following set operators can be used to produce a result data set that contains only records that are not found in the result data set produced by each query after duplicate rows have been eliminated?
|
| ||||||||||
74. | Given the following two tables:
NAMES NAME NUMBER ---------- ------- Wayne Gretzky 99 Jaromir Jagr 68 Bobby Orr 4 Bobby Hull 23 Brett Hull 16 Mario Lemieux 66 Mark Messier 11 POINTS NAME POINTS ---------- ------ Wayne Gretzky 244 Jaromir Jagr 168 Bobby Orr 129 Brett Hull 121 Mario Lemieux 189 Joe Sakic 94 Which of the following statements will display the player name, number, and points for all players that have scored points?
|
| ||||||||||
75. | Which of the following is a valid wildcard character in a LIKE clause of a SELECT statement?
|
| ||||||||||
76. | Given the following tables:
YEAR_2006 EMPID NAME ----- --------------- 1 Jagger, Mick 2 Richards, Keith 3 Wood, Ronnie 4 Watts, Charlie 5 Jones, Darryl 6 Leavell, Chuck YEAR_1962 EMPID NAME ----- --------------- 1 Jagger, Mick 2 Richards, Keith 3 Jones, Brian 4 Wyman, Bill 5 Watts, Charlie 6 Stewart, Ian If the following SQL statement is executed, how many rows will be returned?
SELECT name FROM year_2007 UNION ALL SELECT name FROM year_1962
|
| ||||||||||
77. | Given the following table definition:
SALES -------------------------------------- INVOICE_NO CHAR(20) NOT NULL SALES_DATE DATE SALES_PERSON VARCHAR(25) REGION CHAR(20) SALES_AMT DECIMAL(9,2) Which of the following queries will return SALES information, sorted by SALES_PERSON, from A to Z, and SALES_DATE, from most recent to earliest?
|
| ||||||||||
78. | Given the following statement:
SELECT hyear, AVG(salary) FROM (SELECT YEAR(hiredate) AS hyear, salary FROM employee WHERE salary > 30000) GROUP BY hyear Which of the following describes the result if this statement is executed?
|
| ||||||||||
79. | Which two of the following statements are true about the HAVING clause?
|
| ||||||||||
80. | Given the following table definitions:
DEPARTMENT -------------------------- DEPTNO CHAR(3) DEPTNAME CHAR(30) MGRNO INTEGER ADMRDEPT CHAR(3) EMPLOYEE -------------------------- EMPNO INTEGER FIRSTNAME CHAR(30) MIDINIT CHAR LASTNAME CHAR(30) WORKDEPT CHAR(3) Which of the following statements will list every employee number and last name, along with the employee number and last name of their manager, including employees that have not been assigned to a manager?
|
| ||||||||||
81. | Given the following table:
EMPLOYEE EMPID NAME INSTRUMENT --- --------------- ----- 1 Jagger, Mick 01 2 Richards, Keith 02 3 Wood, Ronnie 02 4 Watts, Charlie 03 5 Jones, Darryl 04 6 Leavell, Chuck 05 If the following query is executed:
SELECT name, CASE WHEN instrument = '01' THEN 'HARMONICA' WHEN instrument = '02' THEN 'GUITAR' WHEN instrument = '03' THEN 'DRUMS' ELSE 'UNKNOWN' END AS instrument FROM employee What will be the results?
|
| ||||||||||
82. | Given the following UPDATE statement:
UPDATE employees SET workdept = (SELECT deptno FROM department WHERE deptno = 'A01') WHERE workdept IS NULL Which of the following describes the result if this statement is executed?
|
| ||||||||||
83. | Given the following table:
CURRENT_EMPLOYEES -------------------------- EMPID INTEGER NOT NULL NAME CHAR(20) SALARY DECIMAL(10,2) PAST_EMPLOYEES -------------------------- EMPID INTEGER NOT NULL NAME CHAR(20) SALARY DECIMAL(10,2) Assuming both tables contain data, which of the following statements will NOT successfully add data to table CURRENT_EMPLOYEES?
|
| ||||||||||
84. | Given the following table definition:
SALES -------------------------- SALES_DATE DATE SALES_PERSON CHAR(20) REGION CHAR(20) SALES INTEGER Which of the following SQL statements will remove all rows that had a SALES_DATE in the year 1995?
|
| ||||||||||
85. | Given the following table definition:
EMPLOYESS -------------------------- EMP ID INTEGER NAME CHAR(20) DEPT CHAR(10) SALARY DECIMAL (10, 2) COMMISSION DECIMAL (8, 2) Assuming the DEPT column contains the values ‘ADMIN’, ‘PRODUCTION’, and ‘SALES’, which of the following statements will produce a result data set in which all ADMIN department employees are grouped together, all PRODUCTION department employees are grouped together, and all SALES department employees are grouped together?
|
| ||||||||||
86. | The following SQL statement:
DELETE FROM tab1 WHERE CURRENT OF csr1 WITH RR Is used to perform which type of delete operation?
|
| ||||||||||
87. | Given the following data:
TAB1 C1 C2 -- --- 200 abc 250 abc 150 def 300 ghi 175 def If the following query is executed:
WITH subset (col1, col2) AS (SELECT c1, c2 FROM tab1 WHERE c1 > 150) SELECT col2, SUM(col1) AS col1_sum FROM subset GROUP BY col2 ORDER BY col2 Which of the following result data sets will be produced?
|
| ||||||||||
88. | Given the following table definitions:
TABLE1 ----------------------------------- ID INT NAME CHAR(30) PERSON INT CITIES INT TABLE2 ----------------------------------- ID INT LASTNAME CHAR(30) Which of the following statements will remove all rows in table TABLE1 that have matching PERSONs in table TABLE2?
|
| ||||||||||
89. | Given the following two tables:
NAMES NAME NUMBER ----------- -------------- Wayne Gretzky 99 Jaromir Jagr 68 Bobby Orr 4 Bobby Hull 23 Brett Hull 16 Mario Lemieux 66 Mark Messier 11 POINTS NAME POINTS ----------- -------------- Wayne Gretzky 244 Jaromir Jagr 168 Bobby Orr 129 Brett Hull 121 Mario Lemieux 189 Joe Sakic 94 Which of the following statements will display the player name, number, and points for all players that have scored points?
|
| ||||||||||
90. | Given the following table definitions:
EMPLOYEES ------------------------------------------------ EMPID INTEGER NAME CHAR(20) DEPTID CHAR(3) SALARY DECIMAL(10,2) COMMISSION DECIMAL(8,2) DEPARTMENTS ------------------------------------------------ DEPTNO INTEGER DEPTNAME CHAR(20) Which of the following statements will produce a result data set that satisfies all of these conditions:
|
| ||||||||||
91. | Given the following table:
CURRENT_EMPLOYEES -------------------------------------- EMPID INTEGER NOT NULL NAME CHAR(20) SALARY DECIMAL(10,2) PAST_EMPLOYEES -------------------------------------- EMPID INTEGER NOT NULL NAME CHAR(20) SALARY DECIMAL(10,2) Assuming both tables contain data, which of the following statements will NOT successfully add data to table CURRENT_EMPLOYEES?
|
| ||||||||||
92. | Given the following table:
STOCK -------------------------- CATEGORY CHAR(1) PARTNO CHAR(12) DESCRIPTION VARCHAR(40) QUANTITY INTEGER PRICE DEC(7,2) If items are indicated to be out of stock by setting DESCRIPTION to NULL and QUANTITY and PRICE to zero, which of the following statements updates the STOCK table to indicate that all items except those with CATEGORY of ‘S’ are temporarily out of stock?
|
| ||||||||||
93. | Given the following SQL statements:
CREATE TABLE tab1 (col1 INTEGER) INSERT INTO tab1 VALUES (NULL) INSERT INTO tab1 VALUES (1) CREATE TABLE tab2 (col2 INTEGER) INSERT INTO tab2 VALUES (NULL) INSERT INTO tab2 VALUES (1) INSERT INTO tab2 VALUES (2) What will be the result when the following statement is executed?
SELECT * FROM tab1 WHERE col1 IN (SELECT col2 FROM tab2)
|
| ||||||||||
94. | Given the following table definition:
SALES --------------------------------------------- INVOICE_NO CHAR(20) NOT NULL SALES_DATE DATE SALES_PERSON CHAR(20) REGION CHAR(20) SALES INTEGER If the following SELECT statement is executed, which of the following describes the order of the rows in the result data set produced?
SELECT * FROM sales
|
| ||||||||||
95. | Given the following tables:
YEAR_2006 EMPID NAME --------------------------------- 1 Jagger, Mick 2 Richards, Keith 3 Wood, Ronnie 4 Watts, Charlie 5 Jones, Darryl 6 Leavell, Chuck YEAR_1962 EMPID NAME --------------------------------- 1 Jagger, Mick 2 Richards, Keith 3 Jones, Brian 4 Wyman, Bill 5 Chapman, Tony 6 Stewart, Ian If the following SQL statement is executed, how many rows will be returned?
SELECT name FROM year_2006 UNION SELECT name FROM year_1962
|
| ||||||||||
96. | Which of the following best describes a unit of work?
|
| ||||||||||
97. | Given the following set of statements:
CREATE TABLE tab1 (col1 INTEGER, col2 CHAR(20)); COMMIT; INSERT INTO tab1 VALUES (123, 'Red'); INSERT INTO tab1 VALUES (456, 'Yellow'); SAVEPOINT s1 ON ROLLBACK RETAIN CURSORS; DELETE FROM tab1 WHERE col1 = 123; INSERT INTO tab1 VALUES (789, 'Blue'); ROLLBACK TO SAVEPOINT s1; INSERT INTO tab1 VALUES (789, 'Green'); UPDATE tab1 SET col2 = NULL WHERE col1 = 789; COMMIT; Which of the following records would be returned by the following statement?
SELECT * FROM tab1
|
| ||||||||||
98. | Given the following table:
TAB1 COL1 COL2 ----- ----- A 10 B 20 C 30 D 40 E 50 And the following SQL statements:
DECLARE c1 CURSOR WITH HOLD FOR SELECT * FROM tab1 ORDER BY col_1; OPEN c1; FETCH c1; FETCH c1; FETCH c1; COMMIT; FETCH c1; CLOSE c1; FETCH c1; Which of the following is the last value obtained for COL_2?
|
| ||||||||||
99. | A stored procedure has been created with the following statement:
CREATE PROCEDURE proc1 (IN var1 VARCHAR(10), OUT rc INTEGER) SPECIFIC myproc LANGUAGE SQL … What is the correct way to invoke this procedure from the command line processor (CLP)?
|
| ||||||||||
100. | Given the following table:
TEMP_DATA TEMP DATE ----- ----- 45 12/25/2006 51 12/26/2006 67 12/27/2006 72 12/28/2006 34 12/29/2006 42 12/30/2006 And the following SQL statement:
CREATE FUNCTION degf_to_c (temp INTEGER) RETURNS INTEGER LANGUAGE SQL CONTAINS SQL NO EXTERNAL ACTION DETERMINISTIC BEGIN ATOMIC DECLARE newtemp INTEGER; SET newtemp = temp - 32; SET newtemp = newtemp * 5; RETURN newtemp / 9; END Which two of the following SQL statements illustrate the proper way to invoke the scalar function DEGF_TO_C?
|
| ||||||||||
101. | Given the following CREATE TABLE statement:
CREATE TABLE customer(custid INTEGER, info XML) And the following INSERT statements:
INSERT INTO customer VALUES (1000, '<customerinfo xmlns="http://custrecord.dat" cust> <name>John Doe</name> <addr country="United States"> <street>25 East Creek Drive</street> <city>Raleigh</city> <state-prov>North Carolina</state-prov> <zip-pcode>27603</zip-pcode> </addr> <phone type="work">919-555-1212</phone> <email>john.doe@abc.com</email> </customerinfo>'); INSERT INTO customer VALUES (1000, '<customerinfo xmlns="http://custrecord.dat" cust> <name>Paul Smith</name> <addr country="Canada"> <street>412 Stewart Drive</street> <city>Toronto</city> <state-prov>Ontario</state-prov> <zip-pcode>M8X-3T6</zip-pcode> </addr> <phone type="work">919-555-4444</phone> <email>psmith@xyz.com</email> </customerinfo>'); What is the result of the following XQuery expression?
XQUERY declare default element namespace "http://custrecord.dat"; for $info in db2-fn:xmlcolumn('CUSTOMER.INFO')/customerinfo where $info/addr/state-prov="Ontario" return $info/name/text();
|
| ||||||||||
102. | Which of the following is a valid DB2 data type?
|
| ||||||||||
103. | Which of the following DB2 data types does NOT have a fixed length?
|
| ||||||||||
104. | Which of the following is the best statement to use to create a user-defined data type that can be used to store currency values?
|
| ||||||||||
105. | Which of the following DB2 data types can be used to store 1000 MB of single-byte character data?
|
| ||||||||||
106. | Which of the following DB2 data types can NOT be used to create an identity column?
|
| ||||||||||
107. | Which of the following strings can NOT be inserted into an XML column using XMLPARSE()?
|
| ||||||||||
108. | Which two of the following are optional and do not have to be specified when creating a table?
|
| ||||||||||
109. | Which of the following can NOT be used to restrict specific values from being inserted into a column in a particular table?
|
| ||||||||||
110. | Given the following CREATE TABLE statement:
CREATE TABLE table2 LIKE table1 Which two of the following will NOT occur when the statement is executed?
|
| ||||||||||
111. | If the following SQL statements are executed:
CREATE TABLE tab1 (id SMALLINT NOT NULL PRIMARY KEY, name VARCHAR(25)); CREATE TABLE tab2 (empid SMALLINT, weekno SMALLINT, payamt DECIMAL(6,2), CONSTRAINT const1 FOREIGN KEY (empid) REFERENCES taba(id) ON UPDATE NO ACTION); Which of the following statements is true?
|
| ||||||||||
112. | Which of the following is used to indicate a column will not accept NULL values and can be referenced in another table's foreign key specification?
|
| ||||||||||
113. | If table TAB1 is created using the following statement:
CREATE TABLE tab1 (col1 INTEGER NOT NULL, col2 CHAR(5), CONSTRAINT cst1 CHECK (col1 in (1, 2, 3))) Which of the following statements will successfully insert a record into table TAB1?
|
| ||||||||||
114. | If the following SQL statements are executed:
CREATE TABLE make (makeid SMALLINT NOT NULL PRIMARY KEY, make VARCHAR(25)); CREATE TABLE model (modelid SMALLINT, model VARCHAR(25), makeid SMALLINT, CONSTRAINT const1 FOREIGN KEY (makeid) REFERENCES make(makeid) ON DELETE RESTRICT); And each table created is populated as follows:
MAKE MAKEID MAKE ------ -------- 1 Ford 2 Chevrolet 3 Toyota MODEL MODELID MODEL MAKEID ------- ------- -------- 1 Mustang 1 2 Escort 1 3 Malibu 2 4 Camry 3 If the following SQL statement is executed:
DELETE FROM make WHERE makeid = 1 What is the total number of rows that will be deleted?
|
| ||||||||||
115. | Which of the following is NOT a characteristic of a unique index?
|
| ||||||||||
116. | If the following statement is executed:
CREATE TABLE employee (empid INT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 5), name VARCHAR(20), dept INT CHECK (dept BETWEEN 1 AND 20), hiredate DATE WITH DEFAULT CURRENT DATE, salary DECIMAL(7,2), PRIMARY KEY(empid), CONSTRAINT cst1 CHECK (YEAR(hiredate) > 2006 OR Salary > 60500)); Which of the following INSERT statements will fail?
|
| ||||||||||
117. | Which type of key is defined on the child table to implement a referential constraint?
|
| ||||||||||
118. | Which of the following is NOT true about schemas?
|
| ||||||||||
119. | When does a view get populated?
|
| ||||||||||
120. | Given the following statements:
CREATE TABLE table1 (col1 INTEGER, col2 CHAR(3)); CREATE VIEW view1 AS SELECT col1, col2 FROM table1 WHERE col1 < 100 WITH LOCAL CHECK OPTION; Which of the following INSERT statements will execute successfully?
|
| ||||||||||
121. | Which of the following actions will NOT cause a trigger to be fired?
|
| ||||||||||
122. | The following triggers were defined for a table named SALES in the order shown:
CREATE TRIGGER trigger_a NO CASCADE BEFORE UPDATE ON sales REFERENCING NEW AS new FOR EACH ROW SET new.commission = sale_amt * .05 WHERE invoice = n.invoice; CREATE TRIGGER trigger_b AFTER INSERT ON sales REFERENCING NEW AS new FOR EACH ROW UPDATE sales SET bill_date = CURRENT DATE + 30 DAYS WHERE invoice = n.invoice; CREATE TRIGGER trigger_c NO CASCADE BEFORE DELETE ON sales FOR EACH ROW SIGNAL SQLSTATE '75005' SET MESSAGE_TEXT = 'Deletes not allowed!'; Which of the following statements is NOT true?
|
| ||||||||||
123. | Which of the following CREATE TABLE statements will NOT be successful?
|
| ||||||||||
124. | If the following SQL statement is executed:
CREATE TABLE sales (invoice_no NOT NULL PRIMARY KEY, sales_date DATE, sales_amt NUMERIC(7,2)) IN tbsp0, tbsp1, tbsp2, tbsp3 PARTITION BY RANGE (sales_date NULLS FIRST) (STARTING '1/1/2007' ENDING '12/31/2007' EVERY 3 MONTHS) Which of the following statements is true?
|
| ||||||||||
125. | Which of the following is NOT a characteristic of a declared temporary table?
|
|
Answers
66. | The correct answer is D. When a SELECT statement such as the one shown is executed, the result data set produced will contain all possible combinations of the rows found in each table specified (otherwise known as the Cartesian product). Every row in the result data set produced is a row from the first table referenced concatenated with a row from the second table referenced, concatenated in turn with a row from the third table referenced, and so on. The total number of rows found in the result data set produced is the product of the number of rows in all the individual table-references; in this case, 5 x 5 = 25. | ||||||||||||||||||||||||||||||||||||||||||||||
67. | The correct answer is D. The proper way to test for a missing value (or null) is by using the NULL predicate with a WHERE clause, and answer D shows the correct way to construct such a WHERE clause. Keep in mind that NULL, zero (0), and blank ("") are not the same value. NULL is a special marker used to represent missing information, while zero and blank (empty string) are actual values that can be stored in a column to indicate a specific value (or lack thereof). | ||||||||||||||||||||||||||||||||||||||||||||||
68. | The correct answer is D. When a full outer join operation is performed, rows that would have been returned by an inner join operation, together with all rows stored in both tables of the join operation that would have been eliminated by the inner join operation are returned in the result data set produced. An inner join can be thought of as the cross product of two tables, in which every row in one table that has a corresponding row in another table is combined with that row to produce a new record. When a left outer join operation is performed, rows that would have been returned by an inner join operation, together with all rows stored in the leftmost table of the join operation (i.e., the table listed first in the OUTER JOIN clause) that would have been eliminated by the inner join operation, are returned in the result data set produced. When a right outer join operation is performed, rows that would have been returned by an inner join operation, together with all rows stored in the rightmost table of the join operation (i.e., the table listed last in the OUTER JOIN clause) that would have been eliminated by the inner join operation, are returned in the result data set produced. | ||||||||||||||||||||||||||||||||||||||||||||||
69. | The correct answer is C. The UPDATE statement assigns a NULL value to column C1 and NULL values are displayed as a dash (-). | ||||||||||||||||||||||||||||||||||||||||||||||
70. | The correct answer is B. If the DISTINCT clause is specified with a SELECT statement, duplicate rows are removed from the final result data set returned. Two rows are considered to be duplicates of one another if the value of every column of the first row is identical to the value of the corresponding column of the second row. | ||||||||||||||||||||||||||||||||||||||||||||||
71. | The correct answer is B. The FETCH FIRST clause is used to limit the number of rows that are returned to the result data set produced in response to a query. When used, the FETCH FIRST clause is followed by a positive integer value and the words ROWS ONLY. This tells the DB2 Database Manager that the user/application executing the query does not want to see more than n number of rows, regardless of how many rows might exist in the result data set that would be produced were the FETCH FIRST clause not specified. | ||||||||||||||||||||||||||||||||||||||||||||||
72. | The correct answers are A and E. An inner join can be thought of as the cross product of two tables, in which every row in one table that has a corresponding row in another table is combined with that row to produce a new record. The syntax for a SELECT statement that performs an inner join operation is:
SELECT [* | [Expression] <<AS> [NewColumnName]> ,...] FROM [[TableName] <<AS> [CorrelationName]> ,...] [JoinCondition] where:
The following syntax can also be used to create a SELECT statement that performs an inner join operation:
SELECT [* | [Expression] <<AS> [NewColumnName]> ,...] FROM [[TableName1] <<AS> [CorrelationName1]>] <INNER> JOIN [[TableName2] <<AS> [CorrelationName2]>] ON [JoinCondition] where:
| ||||||||||||||||||||||||||||||||||||||||||||||
73. | The correct answer is C. When the EXCEPT set operator is used, the result data sets produced by each individual query are combined, all duplicate rows found are eliminated, and all records found in the first result data set that have a corresponding record in the second result data set are eliminated, leaving just the records that are not found in both result data sets. When the UNION set operator is used, the result data sets produced by each individual query are combined and all duplicate rows are eliminated; when the INTERSECT set operator is used, the result data sets produced by each individual query are combined, all duplicate rows found are eliminated, and all records found in the first result data set that do not have a corresponding record in the second result data set are eliminated, leaving just the records that are found in both result data sets; and MERGE is not a set operator. | ||||||||||||||||||||||||||||||||||||||||||||||
74. | The correct answer is C. When a right outer join operation is performed, rows that would have been returned by an inner join operation, together with all rows stored in the rightmost table of the join operation (i.e., the table listed last in the OUTER JOIN clause) that would have been eliminated by the inner join operation are returned in the result data set produced. In this case, we want to see all records found in the POINTS table, along with any corresponding records found in the NAMES table, so a right outer join is the appropriate join operation to use. | ||||||||||||||||||||||||||||||||||||||||||||||
75. | The correct answer is A. The pattern of characters specified with the LIKE clause of a SELECT statement can consist of regular alphanumeric characters and/or special metacharacters that are interpreted as follows:
| ||||||||||||||||||||||||||||||||||||||||||||||
76. | The correct answer is D. When the UNION ALL set operator is used, the result data sets produced by each individual query are combined; all duplicate rows found are retained. Thus with this example, the results of both tables are combined (6 rows + 6 rows = 12 rows) and the duplicate rows for "Jagger, Mick", "Richards, Keith", and "Watts, Charlie" are retained. Had the UNION set operator been used instead, the result data sets produced by each individual query would have been combined, all duplicate rows would have been eliminated, and the answer would have been 9 (12 - 3 = 9 rows). | ||||||||||||||||||||||||||||||||||||||||||||||
77. | The correct answer is C. Data is stored in a table in no particular order, and unless otherwise specified, a query only returns data in the order in which it is found. The ORDER BY clause is used to tell the DB2 Database Manager how to sort and order the rows that are to be returned in a result data set produced in response to a query. When specified, the ORDER BY clause is followed by the name of one or more column(s) whose data values are to be sorted and a keyword that indicates the desired sort order. If the keyword ASC follows the column's name, ascending order is used, and if the keyword DESC follows the column name, descending order is used. If no keyword is specified, ascending order is used by default. | ||||||||||||||||||||||||||||||||||||||||||||||
78. | The correct answer is B. The subselect produces a result data set that contains hire year and salary information for each employee whose salary is greater than $30,000.00. The GROUP BY clause is used to tell the DB2 Database Manager how to organize rows of data returned in the result data set produced in response to a query. (The GROUP BY clause specifies an intermediate result table consisting of a group of rows.) In this example, the GROUP BY clause tells the outer SELECT to calculate and group average salary information by hire year. | ||||||||||||||||||||||||||||||||||||||||||||||
79. | The correct answers are B and C. The HAVING clause is used to apply further selection criteria to columns that are referenced in a GROUP BY clause. This clause behaves like the WHERE clause, except that it refers to data that has already been grouped by a GROUP BY clause (the HAVING clause is used to tell the DB2 Database Manager how to select the rows that are to be returned in a result data set from rows that have already been grouped.) And like the WHERE clause, the HAVING clause is followed by a search condition that acts as a simple test that, when applied to a row of data, will evaluate to TRUE, FALSE, or Unknown. | ||||||||||||||||||||||||||||||||||||||||||||||
80. | The correct answer is B. There is no such thing as a RIGHT INNER JOIN or a LEFT INNER JOIN so the statements shown in Answers A and D are invalid. Because we want to get employee records for employees who do not have a manager and because the EMPLOYEE table is listed before the OUTER JOIN clause, the LEFT OUTER JOIN is the correct join to use. | ||||||||||||||||||||||||||||||||||||||||||||||
81. | The correct answer is C. One efficient and concise way to display coded values in a readable format is to use one or more CASE expressions in the selection list of a query. Each CASE operation evaluates a specified expression and supplies a different value, depending on whether a certain condition is met. A CASE expression can take one of two forms: simple or searched. The CASE statement presented in the question is a searched CASE expression; in this example, if the INSTRUMENT column contains the value '01', the word 'HARMONICA' is returned, if the INSTRUMENT column contains the value '02', the word 'GUITAR' is returned, if the INSTRUMENT column contains the value '03', the word 'DRUMS' is returned, and if the INSTRUMENT column contains any other value, the word 'UNKNOWN' is returned. | ||||||||||||||||||||||||||||||||||||||||||||||
82. | The correct answer is B . When the results of a query, or subselect, are used to provide values for one or more columns identified in the column name list provided for an UPDATE statement, the values retrieved from one base table or view are used to modify values stored in another. The number of values returned by the subselect must match the number of columns provided in the column name list specified, and only one record can be returned. | ||||||||||||||||||||||||||||||||||||||||||||||
83. | The correct answer is D. Because the EMPID column in each table was defined in such a way that it does not allow null values, a non-null value must be provided for this column any time data is inserted into either table. The INSERT statement shown in answer D does not provide a value for the EMPID column of the CURRENT_EMPLOYEES table, so the statement will fail. | ||||||||||||||||||||||||||||||||||||||||||||||
84. | The correct answer is B. The DELETE statement is used to remove specific records from a table (the DROP statement completely destroys the table object), and the correct syntax for the DELETE statement is DELETE FROM [TableName] … | ||||||||||||||||||||||||||||||||||||||||||||||
85. | The correct answer is A. The ORDER BY clause is used to tell the DB2 Database Manager how to sort and order the rows that are to be returned in a result data set produced in response to a query. In this example, all rows containing the value “ADMIN” in the DEPT column would be listed first, followed by all rows containing the value “PRODUCTION”, followed by all rows containing the value “SALES”. | ||||||||||||||||||||||||||||||||||||||||||||||
86. | The correct answer is A. Delete operations can be conducted in one of two ways: as searched delete operations or as positioned delete operations. To perform a positioned delete, a cursor must first be created, opened, and positioned on the row to be deleted. Then, the DELETE statement used to remove the row must contain a WHERE CURRENT OF [CursorName] clause (CursorName identifies the cursor being used). Because of their added complexity, positioned delete operations are typically performed by embedded SQL applications. | ||||||||||||||||||||||||||||||||||||||||||||||
87. | The correct answer is B. Common table expressions are mechanisms that are used to construct local temporary tables that reside in memory and only exist for the life of the SQL statement that defines them. The syntax used to construct a common table expression is:
WITH [TableName]<([ColumnName] ,...])> AS ([SELECTStatement]) where:
So in this example, all of the data stored in table TAB1, with the exception of the record "150 - def" is copied to a common table named SUBSET, and then a query is run against this common table. | ||||||||||||||||||||||||||||||||||||||||||||||
88. | The correct answer is C. Since we are looking for values in the PERSON column of TABLE1 that have a matching value in the ID column of TABLE2, the statement shown in Answer C is the only statement that is correct. (The SQL statements shown in Answers B and D are incorrect because there is no PERSON column in TABLE2; the statement shown in Answer A is incorrect because it is looking for values that match those in the ID column in TABLE1, not the PERSON column.) | ||||||||||||||||||||||||||||||||||||||||||||||
89. | The correct answer is C. When a right outer join operation is performed, rows that would have been returned by an inner join operation, together with all rows stored in the rightmost table of the join operation (i.e., the table listed last in the OUTER JOIN clause) that would have been eliminated by the inner join operation are returned in the result data set produced. In this case, we want to see all records found in the POINTS table, along with any corresponding records found in the NAMES table, so a right outer join is the appropriate join operation to use. | ||||||||||||||||||||||||||||||||||||||||||||||
90. | The correct answer is B. COUNT(empno) together with GROUP BY deptname displays the total number of employees in each department; SELECT deptname displays the corresponding department name for each department ID, and ORDER BY 2 DESC sorts the data by employee count (which is column 2) from greatest to least. | ||||||||||||||||||||||||||||||||||||||||||||||
91. | The correct answer is D. Because the EMPID column was defined in such a way that it does not allow null values, a non-null value must be provided for this column anytime data is inserted into either table. The INSERT statement shown in Answer D does not provide a value for the EMPID column of the CURRENT_EMPLOYEES table, so the statement will fail. | ||||||||||||||||||||||||||||||||||||||||||||||
92. | The correct answer is D. Because ‘NULL’ is treated as a string instead of a NULL value, the SQL statements shown in Answers A and C would not set the STATUS to NULL; the statement shown in Answer B is invalid because the SET keyword is only used once in the UPDATE statement. Therefore, statement D is the only UPDATE statement shown that will accomplish the desired task. | ||||||||||||||||||||||||||||||||||||||||||||||
93. | The correct answer is A. The IN predicate is used to define a comparison relationship in which a value is checked to see whether or not it matches a value in a finite set of values. This finite set of values can consist of one or more literal values coded directly in the SELECT statement, or it can be composed of the non-null values found in the result data set generated by a subquery. So in this example, the non-null values that appear in the result data set produced by the subquery are the values 1 and 2, and the only row in TAB1 that has a matching value in COL1 is the row with the value 1 in it. | ||||||||||||||||||||||||||||||||||||||||||||||
94. | The correct answer is D. Data is stored in a table in no particular order, and unless otherwise specified (with an ORDER BY clause), a query only returns data in the order in which it is found. | ||||||||||||||||||||||||||||||||||||||||||||||
95. | The correct answer is C. When the UNION set operator is used, the result data sets produced by each individual query are combined and all duplicate rows are eliminated. Thus with this example, the results of both tables are combined (6 rows + 6 rows = 12 rows) and the duplicate rows for Jagger, Mick and Richards, Keith are removed (12 – 2 = 10 rows). So 10 rows are returned. | ||||||||||||||||||||||||||||||||||||||||||||||
96. | The correct answer is C. A transaction (also known as a unit of work) is a sequence of one or more SQL operations grouped together as a single unit, usually within an application process. A given transaction can perform any number of SQL operations-from a single operation to many hundreds or even thousands, depending on what is considered a "single step" within your business logic. The initiation and termination of a single transaction defines points of data consistency within a database; either the effects of all operations performed within a transaction are applied to the database and made permanent (committed), or the effects of all operations performed are backed out (rolled back) and the database is returned to the state it was in before the transaction was initiated. In most cases, transactions are initiated the first time an executable SQL statement is executed after a connection to a database has been made or immediately after a preexisting transaction has been terminated. Once initiated, transactions can be implicitly terminated using a feature known as "automatic commit" (in this case, each executable SQL statement is treated as a single transaction, and any changes made by that statement are applied to the database if the statement executes successfully or discarded if the statement fails) or they can be explicitly terminated by executing the COMMIT or the ROLLBACK SQL statement. | ||||||||||||||||||||||||||||||||||||||||||||||
97. | The correct answer is C. DB2 uses a mechanism known as a savepoint to allow an application to break the work being performed by a single large transaction into one or more subsets. Once created, a savepoint can be used in conjunction with a special form of the ROLLBACK SQL statement to return a database to the state it was in at the point in time a particular savepoint was created. The syntax for this form of the ROLLBACK statement is:
ROLLBACK <WORK> TO SAVEPOINT <[ SavepointName]> where:
So, in this example, every operation performed between the time savepoint S1 was created and the ROLLBACK TO SAVEPOINT statement was executed was undone. | ||||||||||||||||||||||||||||||||||||||||||||||
98. | The correct answer is C. When a cursor that has been declared with the WITH HOLD option specified (as in the example shown) is opened, it will remain open across transaction boundaries until it is explicitly closed; otherwise, it will be implicitly closed when the transaction that opens it is terminated. In this example, the cursor is opened, the first three rows are fetched from it, the transaction is committed (but the cursor is not closed), another row is fetched from it, and then the cursor is closed. Thus, the last value obtained will be:
TAB1 --------------- COL1 COL2 ---- --- D 40 | ||||||||||||||||||||||||||||||||||||||||||||||
99. | The correct answer is A. The CALL statement is used to invoke a stored procedure, so answer D is wrong; because a stored procedure cannot be invoked using its specific name, answer B is wrong; and since SALES is a character string value that is being passed to the procedure, it must be enclosed in single quotes. Therefore, answer C is wrong. | ||||||||||||||||||||||||||||||||||||||||||||||
100. | The correct answers are A and B. How a user-defined function is invoked depends a lot on what it has been designed to do; scalar user-defined functions can be invoked as an expression in the select list of a query while table and row functions must be referenced by the FROM clause. In because the user-defined function used in this example is a scalar function that only returns a single value, answer B is the correct way to call it. A scalar function can also be invoked by executing a VALUES statement that looks something like the one shown in answer A. | ||||||||||||||||||||||||||||||||||||||||||||||
101. | The correct answer is A. In XQuery, expressions are the main building blocks of a query. Expressions can be nested and form the body of a query. A query can also have a prolog that contains a series of declarations that define the processing environment for the query. Thus, if you wanted to retrieve customer names for all customers who reside in North Carolina from XML documents stored in the CUSTINFO column of a table named CUSTOMER (assuming this table has been populated with the INSERT statement we looked at earlier), you could do so by executing an XQuery expression that looks something like this:
XQUERY declare default element namespace "http://custrecord.dat"; for $info in db2-fn:xmlcolumn('CUSTOMER.CUSTINFO')/customerinfo where $info/addr/state-prov="North Carolina" return $info/name And when this XQuery expression is executed from the Command Line Processor, it should return information that looks like this (again, assuming this table has been populated with the INSERT statement we looked at earlier):
1 ------------------------------ <name xmlns="http://custrecord.dat">John Doe</name> If you wanted to remove the XML tags and just return the customer name, you could do so by executing an XQuery expression that looks like this instead:
XQUERY declare default element namespace "http://custrecord.dat"; for $info in db2-fn:xmlcolumn('CUSTOMER.CUSTINFO')/customerinfo where $info/addr/state-prov="North Carolina" return $info/name/text() Now, when the XQuery expression is executed from the Command Line Processor, it should return information that looks like this:
1 ------- John Doe | ||||||||||||||||||||||||||||||||||||||||||||||
102. | The correct answer is D. NUMBER, INTERVAL, and BYTE are not valid DB2 data types. The terms DECIMAL, DEC, NUMERIC, and NUM are used to denote the decimal data type. The decimal data type is used to store numeric values that contain both whole and fractional parts, separated by a decimal point. The exact location of the decimal point is determined by the precision and the scale of the value (the scale is the number of digits used by the fractional part). The maximum precision allowed for decimal values is 31 digits, and the corresponding scale must be a positive number less than the precision of the number. If no precision or scale is specified, a scale of 5 and a precision of 0 is used by default - DECIMAL(5,0). | ||||||||||||||||||||||||||||||||||||||||||||||
103. | The correct answer is C. The XML data type is used to store XML documents in their native format. The amount of storage space set aside to store an XML document varies and is determined in part, by the size and characteristics of the XML document being stored. The integer data type is used to store numeric values that have a precision of 10 digits. The range for integer values is -2,147,483,648 to 2,147,483,647, and 4 bytes of storage space is required for every integer value stored. The terms INTEGER and INT are used to denote the integer data type. The fixed-length character string data type is used to store character string values that are between 1 and 254 characters in length. The amount of storage space needed to store a fixed-length character string value can be determined by solving the following equation: (Number of characters x 1) = Bytes required. (A fixed amount of storage space is allocated, even if all of the space allocated is not needed-short strings are padded with blanks.) The terms CHARACTER and CHAR are used to denote the fixed-length character string data type. The double-precision floating-point data type is used to store a 64-bit approximation of a real number. This number can be zero, or it can fall within the range -1.79769E+308 to -2.225E-307 or 2.225E-307 to 1.79769E+308. Each double-precision floating-point value can be up to 53 digits in length, and 8 bytes of storage space is required for every value stored. The terms DOUBLE, DOUBLE PRECISION, and FLOAT are used to denote the double-precision floating-point data type. | ||||||||||||||||||||||||||||||||||||||||||||||
104. | The correct answer is A. The decimal data type is used to store numeric values that contain both whole and fractional parts, separated by a decimal point. The terms DECIMAL, DEC, NUMERIC, and NUM are used to denote the decimal data type. Since currency values contain both whole and fractional parts, the decimal data type is the best choice to base a userdefined data type on. And to create a distinct data type named CURRENCY that can be used to store numeric data you would execute a CREATE DISTINCT TYPE SQL statement that looks like the one shown in Answer A. | ||||||||||||||||||||||||||||||||||||||||||||||
105. | The correct answer is B. The character large object (CLOB) data type is used to store single-byte character data. The binary large object (BLOB) data type is used to store binary data; the double-byte character large object (DBCLOB) data type is used to store double-byte character data; and the fixed-length double-byte character string (GRAPHIC) data type is used to store double-byte character data strings. | ||||||||||||||||||||||||||||||||||||||||||||||
106. | The correct answer is D. The data type assigned to an identity column must be a numeric data type with a scale of 0; therefore, the only data types that can be assigned to an identity column are: SMALLINT, INTEGER, BIGINT, DECIMAL/NUMERIC, or a user-defined data type that is based on one of these data types. | ||||||||||||||||||||||||||||||||||||||||||||||
107. | The correct answer is C. The XMLPARSE function parses a character string and returns an XML value; the character string expression to be parsed must evaluate to a well-formed XML document that conforms to XML 1.0, as modified by the XML Namespaces recommendation. Answers A, B, and D are character strings that are comprised of a starting tag, an optional value, and a corresponding ending tag. As a result, these strings can be converted into a well-formed, but small, XML documents. | ||||||||||||||||||||||||||||||||||||||||||||||
108. | The correct answers are C and E. At a minimum, when a new table is created, a table name, one or more column names, and corresponding column data types must be specified. Primary keys, constraints (NOT NULL, default, check, unique, referential integrity, and informational), and table space information is optional and is not required. | ||||||||||||||||||||||||||||||||||||||||||||||
109. | The correct answer is D. A unique index, a check constraint, and a referential constraint place restrictions on what can and cannot be stored in the column(s) they are associated with. A default constraint, however, is used to provide a default value for a particular column if no data is provided for that column when data is inserted into a table; if a value is provided for the column, the default value is ignored. | ||||||||||||||||||||||||||||||||||||||||||||||
110. | The correct answers are D and E. When the CREATE TABLE … LIKE … statement is executed, each column of the table that is created will have exactly the same name, data type and nullability characteristic as the columns of the source table used to create the new table. Furthermore, if the EXCLUDING COLUMN DEFAULTS option is not specified (which is the case in this example), all column defaults will be copied as well. However, the new table will not contain any unique constraints, foreign key constraints, triggers, or indexes that exist in the original. | ||||||||||||||||||||||||||||||||||||||||||||||
111. | The correct answer is A. The Insert Rule for a referential constraint guarantees that a value can never be inserted into the foreign key of a child table unless a matching value can be found in the corresponding parent key of the associated parent table. Any attempt to insert records into a child table that violates this rule will result in an error, and the insert operation will fail. The Insert Rule for a referential constraint is implicitly created when the referential constraint itself is created. In this example, the EMPID column of table TAB2 is a foreign key (in a child table) that references the ID column (the parent key) of table TAB1 (the parent table). Therefore, because of the Insert Rule, values cannot be added to the EMPID column of table TAB2 that do not already exist in the ID column of table TAB1. | ||||||||||||||||||||||||||||||||||||||||||||||
112. | The correct answer is B. A unique constraint can be used to ensure that the value(s) assigned to one or more columns when a record is added to a base table are always unique; once a unique constraint has been defined for one or more columns, any operation that attempts toplace duplicate values in those columns will fail. Although a unique, system-required index is used to enforce a unique constraint, there is a distinction between defining a unique constraint and creating a unique index; even though both enforce uniqueness, a unique index allows NULL values and generally cannot be used in a referential constraint. A unique constraint on the other hand, does not allow NULL values and can be referenced in a foreign key specification. (The value "NULL" means a column's value is undefined and distinct from any other value, including other NULL values). A check constraint (also known as a table check constraint) can be used to ensure that a particular column in a base table is never assigned an unacceptable value-once a check constraint has been defined for a column, any operation that attempts to place a value in that column that does not meet specific criteria will fail. The default constraint can be used to ensure that a particular column in a base table is assigned a predefined value (unless that value is overridden) each time a record is added to the table. The predefined value provided could be null (if the NOT NULL constraint has not been defined for the column), a user-supplied value compatible with the column's data type, or a value furnished by the DB2 Database Manager. Unlike other constraints, informational constraints are not enforced during insert and update processing. However, the DB2 SQL optimizer will evaluate information provided by an informational constraint when considering the best access plan to use to resolve a query. As a result, an informational constraint may result in better query performance even though the constraint itself will not be used to validate data entry/modification. | ||||||||||||||||||||||||||||||||||||||||||||||
113. | The correct answer is C. A check constraint is used to ensure that a particular column in a base table is never assigned an unacceptable value-once a check constraint has been defined for a column, any operation that attempts to place a value in that column that does not meet specific criteria will fail. Check constraints are comprised of one or more predicates that collectively are known as the check condition. This check condition is compared with the data value provided and the result of this comparison is returned as the value TRUE, FALSE, or Unknown. If the check constraint returns the value TRUE, the value is acceptable, so it is added to the database. If, on the other hand, the check constraint returns the value FALSE or Unknown, the operation attempting to place the value in the database fails, and all changes made by that operation are backed out. In this example, the check constraint CST1 defined for table TAB1 only allows the values 1, 2, or 3 to be entered into column COL1. The INSERT statement shown in Answer C is the only INSERT statement that has a valid value specified for column COL1. | ||||||||||||||||||||||||||||||||||||||||||||||
114. | The correct answer is A. The ON DELETE RESTRICT ensures that whenever a delete operation is performed on the parent table of a referential constraint, the value for the foreign key of each row in the child table will have the same matching value in the parent key of the parent table that it had before the delete operation was performed. Therefore, in this example no row will be deleted from the MAKE because two rows exists in the MODEL table that references the row the DELETE statement is trying to remove. Had the ON DELETE CASCADE definition been used instead, the delete operation would have succeeded and the tables would have looked like this:
On the other hand, if the ON DELETE SET NULL definition had been used, the delete operation would have succeeded and the tables would have looked like this:
| ||||||||||||||||||||||||||||||||||||||||||||||
115. | The correct answer is D. A unique index allows one and only one NULL value; the value "NULL" means a column's value is undefined and distinct from any other value. The remaining characteristics are true for unique indexes. | ||||||||||||||||||||||||||||||||||||||||||||||
116. | The correct answer is D. In this example, the statement "INSERT INTO employee VALUES (DEFAULT, 'Smith', 10, '11/18/2004', 60250.00)" will fail because the hire date and the salary specified violates check constraint CST1 - YEAR(hiredate) > 2006 OR salary > 60500) | ||||||||||||||||||||||||||||||||||||||||||||||
117. | The correct answer is B. To create a referential constraint, you define a primary key, using one or more columns in the parent table, and you define a foreign key for one or more corresponding columns in the child table that reference the parent table's primary key. (The list of column names in the foreign key clause must be identical to the list of column names specified in the primary key OR a unique constraint for the columns in the parent table that are referenced by the foreign key in the child must exist in order for a referential constraint to be successfully created.) | ||||||||||||||||||||||||||||||||||||||||||||||
118. | The correct answer is B. The value assigned to the CURRENT SCHEMA special register is not persistent across database restarts. Therefore, if you assign a value to the CURRENT SCHEMA special register, disconnect from the database, and reconnect, the CURRENT SCHEMA special register will contain your authentication ID - not the value you assigned it earlier. | ||||||||||||||||||||||||||||||||||||||||||||||
119. | The correct answer is D. A view is a named specification of a result table that is populated whenever the view is referenced in an SQL statement. (Each time a view is referenced, a query is executed and the results are retrieved from the underlying table and returned in a table-like format.) Like base tables, views can be thought of as having columns and rows. And in most cases, data can be retrieved from a view the same way it can be retrieved from a table. | ||||||||||||||||||||||||||||||||||||||||||||||
120. | The correct answer is C. If the WITH LOCAL CHECK OPTION clause of with the CREATE VIEW SQL statement is specified, insert and update operations performed against the view that is created are validated to ensure that all rows being inserted into or updated in the base table the view refers to conform to the view's definition (otherwise, the insert/update operation will fail). So what exactly does this mean? Suppose a view was created using the following CREATE VIEW statement:
CREATE VIEW priority_orders AS SELECT * FROM orders WHERE response_time < 4 WITH LOCAL CHECK OPTION Now, suppose a user tries to insert a record into this view that has a RESPONSE_TIME value of 6. The insert operation will fail because the record violates the view's definition. Had the view not been created with the WITH LOCAL CHECK OPTION clause, the insert operation would have been successful, even though the new record would not be visible to the view that was used to add it. Because VIEW1 was created using a SELECT statement that only references rows that have a value less than 100 in COL1 and because VIEW1 was created with the WITH LOCAL CHECK OPTION specified, each value inserted into COL1 (using VIEW1) must be less than 100. In addition, because COL2 was defined using a character data type, all values inserted into COL2 must be enclosed in single quotes. The INSERT statements shown in Answers B and D will fail because the value to be assigned to COL1 exceeds 100; the INSERT statement shown in Answer A will fail because the value "abc" is not enclosed in single quotation marks. | ||||||||||||||||||||||||||||||||||||||||||||||
121. | The correct answer is C. Whenever an insert operation, an update operation, or a delete operation is performed against the subject table or view, a trigger can be activated (fired). | ||||||||||||||||||||||||||||||||||||||||||||||
122. | The correct answer is D. Triggers are only fired if the trigger event they have been designed to watch for takes place against the subject table they are designed to interact with. In this example, no UPDATE trigger was defined; therefore, no triggers are fired when the sales table is updated. Trigger TRIGGER_C will be fired anytime a delete operation is performed against the SALES table and triggers TRIGGER_A and TRIGGER_B will be fired in the order they were created whenever an insert operation is performed against the SALES table. Trigger TRIGGER_A is designed to calculate a sales commission for an invoice based on the sale amount; trigger TRIGGER_B is designed to assign a value to the BILL_DATE column that is 30 days from today; and trigger TRIGGER_C is designed to display an error message whenever anyone tries to delete records from the SALES table. | ||||||||||||||||||||||||||||||||||||||||||||||
123. | The correct answer is A. The XML data type can be used to store well-formed XML documents in their native format. A table can contain any number of XML columns; however each XML column used has the following restrictions:
In addition, XML columns can only be referenced in a check constraint if the check constraint contains the VALIDATED predicate. (The VALIDATED predicate checks to see if an XML value has been validated using the XMLVALIDATE() function. The XMLVALIDATE() function returns a copy of the input XML value, augmented with information obtained from XML schema validation, including default values and type annotations. If the value of the column is null, the result of the VALIDATED predicate is unknown; otherwise, the result is either TRUE or FALSE.) | ||||||||||||||||||||||||||||||||||||||||||||||
124. | The correct answer is B. The SALES table in the example is partitioned such that each quarter's data is stored in a different data partition, and each partition resides in a different table space. Advantages of using table partitioning include:
| ||||||||||||||||||||||||||||||||||||||||||||||
125. | The correct answer is C. Unlike base tables, whose descriptions and constraints are stored in the system catalog tables of the database to which they belong, declared temporary tables are not persistent and can only be used by the application that creates them-and only for the life of the application. (Once the application that created the global temporary table is terminated, any records in the table are deleted and the table itself is destroyed.) When the application that creates a declared temporary table terminates, the rows of the table are deleted, and the definition of the table is dropped. (However, data stored in a temporary table can exist across transaction boundaries.) Another significant difference between the two centers around naming conventions: base table names must be unique within a schema, but because each application that defines a declared temporary table has its own instance of that table, it is possible for many applications to create declared temporary tables that have the same name. And where base tables are created with the CREATE TABLE SQL statement, declared temporary tables are created with the DECLARE GLOBAL TEMPORARY TABLE statement. |