Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
SQL
1. Given a SELECT statement that has a GROUP BY clause.
The HAVING clause uses the same syntax as which other clause?
A. WHERE
B. UNION
C. SUBQUERY
D. ORDER BY
2. Which of the following statements will create an index and prevent table T1 from containing
two or more
rows with the same values for column C1?
A. CREATE UNIQUE INDEX ix1 ON t1 (c1)
B. CREATE DISTINCT INDEX ix1 ON t1 (c1)
C. CREATE UNIQUE INDEX ix1 ON t1 (c1,c2)
D. CREATE DISTINCT INDEX ix1 ON t1 (c1,c2)
4. Which of the following statements eliminates all but one of each set of repeated rows in the
final result
table?
A. SELECT UNIQUE * FROM t1
B. SELECT DISTINCT * FROM t1
C. SELECT * FROM DISTINCT T1
D. SELECT UNIQUE (*) FROM t1
E. SELECT DISTINCT (*) FROM t1
7. Which of the following tasks can be performed using the ALTER TABLESPACE statement?
A. ASSING a bufferpool
B. Change the table space name
C. Change the type of the table space
D. Change the page size of the table space
8.Which two of the following can be done using the ALTER TABLE statement?
A. Add a trigger.
B. Define an index.
C. Drop a table alias.
D. Add an INTEGER column.
E. Define a unique constraint.
9.Which two of the following can be done using the ALTER TABLE statement?
A. Define a trigger.
B. Define a primary key.
C. Add a check constraint.
D. Add a non-unique index.
E. Change a column's name.
10. Which of the following SQL statements can remove all rows from a table named
COUNTRY?
A. DELETE country
B. DELETE FROM country
C. DELETE * FROM country
D. DELETE ALL FROM country
11. Which of the following is the result of the following SQL statement:
ALTER TABLE talbw1 ADD col2 INT WITH DEFAULT
A. The statement fails with a negative SQL code
B. The statement fails because no default value is specified
C. A new column called COL2 is added to TABLE1 and populated with zeros
D. A new column called COL2 is added to TABLE1 and populated with nulls
E. A new column called COL2, which cannot contains nulls, is added to TABLE1
12. Which of the following DDL statements creates a table where employee IDs are unique?
A. CREATE TABLE t1 (employid INTEGER)
B. CREATE TABLE t1 (employid INTEGER GENERATED BY DEFAULT AS IDENTITY)
C. CREATE TABLE t1 (employid INTEGER NOT NULL)
D. CREATE TABLE t1 (employid INTEGER NOT NULL PRIMARY KEY)
13. Given the table T1, created by:
CREATE TABLE t1
(id INTEGER GENERATED BY DEFAULT AS IDENTITY,
c1 CHAR(3)
)
The following SQL statements are issued:
INSERT INTO t1 VALUES (1, �ABC�)
INSERT INTO t1 VALUES (5, �DEF�)
Which of the following values are inserted into the ID column by the following statement?
INSERT INTO t1(c1) VALUES (�XYZ�)?
A. 0
B. 1
C. 2
D. 5
E. 6
28. Given table T1 with 100 rows, which of the following queries will retrieve 10 rows from table
T1?
A. SELECT * FROM t1 MAXIMUM 10 ROWS
B. SELECT * FROM t1 READ 10 ROWS ONLY
C. SELECT * FROM t1 OPTIMIZE FOR 10 ROWS
D. SELECT * FROM t1 FETCH FIRST 10 ROWS ONLY
70.Given table T1 with 100 rows, which of the following queries will retrieve 10 rows from table
T1?
A. SELECT * FROM t1 MAXIMUM 10 ROWS
B. SELECT * FROM t1 TOP 10 ROWS ONLY
C. SELECT * FROM t1 OPTIMIZE FOR 10 ROWS
D. SELECT * FROM t1 FETCH FIRST 10 ROWS ONLY
83.Given table T1 with 100 rows, which of the following queries will retrieve 10 rows from table
T1?
A. SELECT * FROM t1 MAXIMUM 10 ROWS
B. SELECT * FROM t1 TOP 10 ROWS ONLY
C. SELECT * FROM t1 OPTIMIZE FOR 10 ROWS
D. SELECT * FROM t1 FETCH FIRST 10 ROWS ONLY
31. Given table EMPLOYEE with columns EMPNO and SALARY and table JOB with columns
ID and
TITLE, what is the effect of the statement:
UPDATE employee SET salary=salary * 1.15
WHERE salary<15000 OR EXISTS(SELECT 1 FROM job WHERE job.id=employee.empno
AND
job.title=�Mgr�)
A. Only manager that make less than 15,000 are given salary increases
B. Only non-manager that make less than 15,000 are given salary increases
C. Employees that make less than 15,000 but no managers are given salary increases
D. Employees that make less than 15,000 and all managers are given salary increases
90.Given table EMPLOYEE with columns EMPNO and SALARY, and table JOB with columns
ID and
TITLE, what is the effect of the following statement?
UPDATE employee SET salary = salary * 1.15
WHERE salary < 15000 OR
EXISTS (SELECT 1 FROM job WHERE job.id = employee.empno AND job.title =
'MANAGER')
A. Employees who make less than 15,000 and all managers are given salary increases.
B. Only employees who are managers that make less than 15,000 are given salary increases.
C. Employees who are not managers and who make less than 15,000 are given salary increases.
D. Only employees who are not managers or make less than 15,000 are given salary increases.
55. With DBADM authority on the database and given the statements:
CREATE TABLE t1 (c1 CHAR(1))
INSERT INTO t1 VALUES (�b�)
CREATE VIEW v1 AS SELECT c1 FROM t1 WHERE c1=�a� WITH CHECK OPTION
INSERT INTO v1 VALUES(�a�)
INSERT INTO v1 VALUES(�b�)
How many rows would be returned from the statement, SELECT c1 FROM t1?
A. 0
B. 1
C. 2
D. 3
56. With DBADM authority on the database and given the statements:
CREATE TABLE t1 (c1 CHAR(1))
INSERT INTO t1 VALUES (�b�)
CREATE VIEW v1 AS SELECT c1 FROM t1 WHERE c1=�a�
INSERT INTO v1 VALUES(�a�)
INSERT INTO v1 VALUES(�b�)
How many rows would be returned from the statement, SELECT c1 FROM t1?
A. 0
B. 1
C. 2
D. 3
57.Assuming the proper privileges, which two of the following would allow access to data in a
table T1
using the name A1?
A.CREATE ALIAS a1 FOR t1
B.CREATE TABLE a1 LIKE t1
C.CREATE INDEX a1 ON t1 (col1)
D.CREATE VIEW a1 AS SELECT * FROM t1
E.CREATE TRIGGER trig1 AFTER INSERT ON t1 FOR EACH ROW MODE DB2SQL INSERT
INTO a1
58.Given the following statements:
CREATE TABLE t1
(c1 INTEGER,
c2 INTEGER,
c3 DECIMAL(15,0 ))
INSERT INTO t1 VALUES (1, 2, 3.0)
Which of the following will cause C1 to be decremented each time a row is deleted from the T2
table?
A. ALTER TABLE t1
ADD CHECK(t2)
c1 = c1 - 1
B. CREATE VIEW v1 (c1)
AS (SELECT COUNT(*) FROM t2)
C. ALTER TABLE t1
ADD FOREIGN KEY (c1)
REFERENCES t2
ON DELETE CASCADE
D. CREATE TRIGGER trig1
AFTER DELETE ON t2
FOR EACH ROW MODE DB2SQL
UPDATE t1 SET c1 = c1 – 1
59.Table T1 should only allow values of 1, 2, and 3 in column C1. Which of the following will
cause the
database manager to enforce this business requirement?
A. Delete trigger on T1
B.Check constraint on C1
C.Table level lock on T1
D.Update permission on C1
82.Table T1 has a column C1 char(3) that contains strings in upper and lower case letters.
Which of the
following queries will find all rows where C1 is the string 'ABC' in any case?
A. SELECT * FROM t1 WHERE c1 = 'ABC'
B. SELECT * FROM t1 WHERE UCASE(c1) = 'ABC'
C. SELECT * FROM t1 WHERE IGNORE_CASE(c1 = 'ABC')
D. SELECT * FROM t1 WHERE c1 = 'ABC' WITH OPTION CASE INSENSITIVE
94.A stored procedure has been created with the following statement:
CREATE PROCEDURE P1(IN VAR1 VARCHAR(10), INOUT VAR2 VARCHAR(10), OUT
VAR3 INT)...
From the command line processor (CLP), which is the correct way to call this procedure?
A. Call P1(?,?,?)
B. Call P1("DB2",?,?)
C. Call P1("DB2","DB2",?)
D. Call P1('DB2','DB)
����
100. If a table is defined with a check constraint for one or more columns, which of the following
will
perform the data validation after the table is loaded with the load utility?
A. Reorg
B. Check
C. Runstats
D. Image Copy
E. Set Constraints
101. Which of the following DELETE RULES on CREATE TABLE will delete a dependent
table row if the
parent table row is deleted?
A. ON DELETE REMOVE
B. ONDELETE CASCADE
C. ON DELETE RESTRICT
D. ON DELETE SET NULL
E. ON DELETE PROPAGATE
102. A table has had check constraint enforcement turned off, and additional data has been
inserted. Which
of the following will perform data validation to ensure that column values are valid?
A. Add a trigger
B. Collect statistics
C. Reorganize the table
D. Enable check constraints
103. When constraint checking is suspended or disabled, a table or table space (depending on
platform) is
placed in which of the following states?
A. Paused
B. Check pending
C. Intent locked
D. Constraint waiting
��
104.When granted to USER1, which of the following will allow USER1 to ONLY access table
data?
A. Administrative authority
B. SELECT privilege on the table
C. REFERENCES privilege on the table
D. SELECT privilege WITH GRANT OPTION on the table
118. When granted to user1, which of the following will allow user1 to ONLY access table data?
A. DBADM authority
B. SYSADM authority
C. SELECT privilege on the table
D. SELECT privilege WITH GRANT OPTION on the table
105. Given the following users and groups with no privileges on table t1:
GroupA GroupB
------ ------
user1 user4
user2 user5
user3
Which of the following commands gives all users in the above groups the ability to create a view
on table t1?
A. GRANT SELECT ON TABLE t1 TO ALL
B. GRANT SELECT ON TABLE t1 TO PUBLIC
C. GRANT REFERENCES ON TABLE t1 TO ALL
D. GRANT SELECT ON TABLE t1 TO USER GroupA, GroupB
107. USER3 is running a program A.APP1 that calls stored procedure P.PROC1.
As an administrator, which of the following statements should be executed to give USER3 the
appropriate
privilege to be able to execute the code found in stored procedure P.PROC1?
A. GRANT EXECUTE ON PACKAGE a.app1 TO user3
B. GRANT EXECUTE ON PROCEDURE a.app1 TO user3
C. GRANT EXECUTE ON FUNCTION p.proc1 TO user3
D. GRANT EXECUTE ON PROCEDURE p.proc1 TO user3
109. A user defined function named F.FOO has an input parameter of an integer.
USER4 executes the f ollowing SQL statement:
SELECT col1, col2 FROM t.tab1 WHERE f.foo(col1) < 6;
Which of the following statements grants USER4 the privilege needed to be able
to execute the user defined function?
A. GRANT USE ON FUNCTION f.foo(INT) TO user4
B. GRANT SELECT ON FUNCTION f.foo(INT) TO user4
C. GRANT EXECUTE ON FUNCTION f.foo(INT) TO user4
D. GRANT REFERENCES ON FUNCTION f.foo(INT) TO user4
110 Given a user defined function, U.UDF1, that takes an input parameter of type
INTEGER, and USER6 running the following SQL statement:
SELECT w.udf1(col6) FROM t.tab1 WHERE col4 = 'ABC'
Which of the following statement(s) would allow USER6 to execute the statement?
A. GRANT ALL PRIVILEGES ON TABLE t.tab1 TO user6
B. GRANT SELECT ON TABLE t.tab1 TO user6
C. GRANT SELECT ON TABLE t.tab1 TO user6
GRANT REFERENCES ON FUNCTION u.udf1( INT) TO user6
D. GRANT ALL PRIVILEGES ON TABLE t.tab1 TO user6
GRANT EXECUTE ON FUNCTION u.udf1(INT) TO user6
112. Which of the following will give USER6 the ability to give SELECT privilege on table T.T1
to other
users?
A. GRANT SELECT ON TABLE t.t1 TO user6
B. GRANT ALL PRIVILEGES ON TABLE t.t1 TO user6
C. GRANT USE ON TABLE t.t1 TO user6 WITH GRANT OPTION
D. GRANT ALL PRIVILEGES ON TABLE t.t1 TO user6 WITH GRANT OPTION
113. Which of the following delete rules will not allow a row to be deleted from the parent table
if a row
with the corresponding key value still exists in the child table?
A. DELETE
B. CASCADE
C. RESTRICT
D. SET NULL
116. Which of the following SQL statements sets the default qualifier to �user1�?
A. SET CURRENT ID =�user1�
B. SET CURRENT USER=�user1�
C. SET CURRENT SQLID=�user1�
D. SET CURRENT QUALIFIER=�user1�
119. A user creates the table TABLE1. Which of the following statements would explicitly give
USER1 the
ability to read rows from the table?
A. GRANT VIEW TO user1 ON TABLE table1
B. GRANT READ TO user1 ON TABLE table1
C. GRANT SELCET ON TABLE table1 TO user1
D. GRANT ACCESS ON TABLE table1 TO user1
120. Which of the following can occur once connected to a database or DRDA server with an
explicit
authorization name?
A. Omit a user’s password
B. Change a user’s password if the server supports this function
C. Omit the name of the database or DRDA server if it is local
D. Use the commit option on the connect statement to commit in-doubt units of work from a previous
connection that was terminated