Test your knowledge of DB2 9 by answering the questions below, which are from a real, previous DB2 9 Fundamentals certification exam (Exam 730). When you make your answer selection, click on "Get Answer" to check your answers and read the explanations. If you haven't done so already, be sure to answer the sample questions in Part 2 of this DB2 quiz series about tables.

Sample Questions
Question 1
User USER1 holds CONTROL privilege on table TABLE1. Which two of the following statements is user USER1 allowed to execute?
A. GRANT CONTROL ON table1 TO user2
B. GRANT LOAD ON table1 TO user2
C. GRANT INSERT, UPDATE ON table1 TO user2 WITH GRANT OPTION
D. GRANT BINDADD ON table1 TO PUBLIC
E. GRANT ALL PRIVILEGES ON table1 TO PUBLIC
Get answer

Question 2
Given the following statements:
CREATE TABLE t1 (c1 INTEGER, c2 CHAR(5));
CREATE TABLE t1audit (user VARCHAR(20), date DATE, action VARCHAR(20));
CREATE TRIGGER trig1 AFTER INSERT ON t1
FOR EACH ROW
MODE DB2SQL
INSERT INTO t1audit VALUES (CURRENT USER, CURRENT DATE, 'Insert');
If user USER1 executes the following statements:
INSERT INTO t1 VALUES (1, 'abc');
INSERT INTO t1 (c1) VALUES (2);
UPDATE t1 SET c2 = 'ghi' WHERE c1 = 1;
How many new records will be written to the database?
Get answer

Question 3
Given the requirements to store customer names, billing addresses, and telephone numbers, which of the following would be the best way to define the telephone number column for a table if all customers were located in the same country?
A. PHONE CHAR(15)
B. PHONE VARCHAR(15)
C. PHONE LONG VARCHAR
D. PHONE CLOB(1K)
Get answer

Question 4
Which of the following is NOT a difference between a unique index and a primary key?
A. A primary key is a special form of a unique constraint; both use a unique index.
B. Unique indexes can be defined over one or more columns; primary keys can only be defined on a single column.
C. A table can have many unique indexes but only one primary key.
D. Unique indexes can be defined over one or more columns that allow null values; primary keys cannot contain null values.
Get answer

Question 5
User USER1 wants to utilize an alias to remove rows from a table. Assuming USER1 has no authorities or privileges, which of the following privileges are needed?
A. DELETE privilege on the table
B. DELETE privilege on the alias
C. DELETE privilege on the alias; REFERENCES privilege on the table
D. REFERENCES privilege on the alias; DELETE privilege on the table
Get answer

Question 6
Given the following statements:
CREATE TABLE tab1 (c1 INTEGER, c2 CHAR(5));
CREATE VIEW view1 AS SELECT c1, c2 FROM tab1 WHERE c1 < 100;
CREATE VIEW view2 AS SELECT c1, c2 FROM view1
WITH CASCADED CHECK OPTION;
Which of the following INSERT statements will fail to execute?
A. INSERT INTO view2 VALUES(50, 'abc')
B. INSERT INTO view1 VALUES (100, 'abc')
C. INSERT INTO view2 VALUES(150, 'abc')
D. INSERT INTO view1 VALUES(100, 'abc')
Get answer

Question 7
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?
A. INSERT INTO current_employees (empid) VALUES (10)
B. INSERT INTO current_employees VALUES (10, 'JAGGER', 85000.00)
C. INSERT INTO current_employees SELECT empid, name, salary FROM past_employees WHERE empid = 20
D. INSERT INTO current_employees (name, salary) VALUES (SELECT name, salary FROM past_employees WHERE empid = 20)
Get answer

Question 8
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?
A. Once a row has been added to the SALES table, it cannot be removed
B. Whenever a row is inserted into the SALES table, the value in the BILL_DATE column is automatically set to 30 days from today
C. Each time a row is inserted into the SALES table, trigger TRIGGER_A is fired first, followed by trigger
D. Whenever a row in the SALES table is updated, all three triggers are fired but nothing happens because none of the triggers have been coded to trap update operations
Get answer

Question 9
If the following SQL statements are executed in the order shown:
CREATE TABLE orders
(order_num INTEGER NOT NULL,
buyer_name VARCHAR(35),
amount NUMERIC(5,2));
CREATE UNIQUE INDEX idx_orderno ON orders(order_num);
Which of the following describes the resulting behavior?
A. Every ORDER_NUM value entered must be unique; whenever the ORDERS table is queried rows should be displayed in order of increasing ORDER_NUM values
B. Every ORDER_NUM value entered must be unique; whenever the ORDERS table is queried rows will be displayed in no particular order
C. Duplicate ORDER_NUM values are allowed; no other index can be created for the ORDERS table that reference the ORDER_NUM column
D. Every ORDER_NUM value entered must be unique; no other index can be created for the ORDERS table that reference the ORDER_NUM column
Get answer

Question 10
A table named DEPARTMENT has the following columns:
DEPT_ID
DEPT_NAME
MANAGER
AVG_SALARY
Which of the following is the best way to prevent most users from viewing AVG_SALARY data?
A. Encrypt the table's data
B. Create a view that does not contain the AVG_SALARY column
C. Revoke SELECT access for the AVG_SALARY column from users who should not see AVG_SALARY data
D. Store AVG_SALARY data in a separate table and grant SELECT privilege for that table to the appropriate users
Get answer
