DB2 Database Fundamentals
Covers DB2 database concepts including SQL operations, constraints, data types, sequences, stored procedures, and DB2 objects
Questions
Which of the following database objects is considered executable using SQL?
- View
- Table
- Routine
- Package
A user utilizing an alias to update a subset of columns in a table must have UPDATE privileges on which of the following DB2 objects?
- Table
- Columns
- Table and Alias
- Columns and Alias
In which of the following scenarios would a stored procedure be beneficial?
- An application running on a remote client needs to be able to convert degrees Celsius to degrees Fahrenheit and vice versa
- An application running on a remote client needs to collect three input values, perform a calculation using the values provided, and store the input data, along with the results of the calculation in two different base tables
- An application running on a remote client needs to track every modification made to a table that contains sensitive data
- An application running on a remote client needs to ensure that every new employee that joins the company is assigned a unique, sequential employee number
A programmer wants to generate values for a numeric ID column in their EXPENSE table. The ID column values need to be incremented by 1000 for each new expense report added to the EXPENSE table. Which DB2 object can be referenced by an INSERT statement to meet thisrequirement?
- Sequence
- Table Function
- Identity Column
- INSTEAD OF Trigger
Given the following DDL for the PARTS table: CREATE TABLE parts (part_no INT(9) NOT NULL, part_name VARCHAR(24), part_remain INT(9)); All part numbers entered will be different and all rows should be displayed in order of increasing part numbers whenever the table is queried. Which of the following create index statements will meet this criteria and require the least amount of storage for the index object?
- CREATE UNIQUE INDEX idx_partno ON parts(part_no)
- CREATE UNIQUE INDEX idx_partno ON parts(part_name ASC)
- CREATE UNIQUE INDEX idx_partno ON parts(part_name, part_no ASC)
- CREATE UNIQUE INDEX idx_partno ON parts(part_no, part_name ASC)
What type of constraint can be used to ensure that, in any given row in a table, the value of one column never exceeds the value of another column?
- Check
- Range
- Referential
- Informational
Which of the following will DELETE all of the rows from table T03?
- DELETE * FROM TABLE T03
- DELETE ALL FROM T03
- DELETE * FROM T03
- DELETE FROM T03
Which of the following can NOT be done using the ALTER TABLE statement?
- Add a new column
- Drop a check constraint
- Change a column's name
- Change the length of a VARCHAR column
Which of the following will be a consequence of defining the column IDCOL2 in TABLE2 as a foreign key referencing the primary key (IDCOL1) of TABLE1?
- DB2 will no longer allow updating the value of IDCOL1 in TABLE1.
- When inserting a row in TABLE2, the only values that DB2 will allow for IDCOL2 are the existing values of IDCOL1.
- When inserting a row in TABLE2, DB2 will only allow foreign values for IDCOL2, that is values which do not exist in IDCOL1.
- When a SELECT statement joins TABLE1 with TABLE2, DB2 will automatically add the condition TABLE1.IDCOL1=TABLE2.IDCOL2 if not specified in the statement
Table TABLE1 needs to hold specific numeric values up to 9999999.999 in column COL1. COL1 is also used to perform arithmetic operations. Which of the following would be the most appropriate DB2 data type to use for column COL1?
- INTEGER
- REAL
- NUMERIC(7, 3)
- DECIMAL(10, 3)
Which of the following DB2 objects are publicly referenced names that require no special authority or privilege to use them?
- View
- Alias
- Table
- Package
A sequence was created with the DDL statement shown below: CREATE SEQUENCE my_sequence CACHE 10 ORDER The following statements are successfully executed in sequence through separate database connections: CONNECTION1 - VALUES NEXT VALUE FOR my_sequence INTO :con1hvar CONNECTION2 VALUES NEXT VALUE FOR my_sequence INTO :con2hvar CONNECTION1 - VALUES NEXT VALUE FOR my_sequence INTO :con1hvar What is the current value of the :con1hvar host variable?
- 2
- 3
- 11
- 30
A sequence was created with the DDL statement shown below: CREATE SEQUENCE my_seq START WITH 5 INCREMENT BY 5 CACHE 5 User1 successfully executes the following statements in Connections VALUES NEXT VALUE FOR my_seq INTO :con1hvar VALUES NEXT VALUE FOR my_seq INTO :con1hvar User2 successfully executes the following statement in Connection2: VALUES NEXT VALUE FOR my_seq INTO :con2hvar After User1 & User2 are finished, User3 executes the following statement in Connection3: SELECT NEXT VALUE FOR my_seq FROM sysibm.sysdummy1 Which value will be returned by the query?
- 20
- 25
- 50
- 55
A DRDA host database resides on a z/OS or an i5/OS system and listens on port 446. The TCP/IP address for this system is 192.168.10.1 and the TCP/IP host name is myhost. Which of the following commands is required to update the local node directory so that a DB2 client can access this DRDA database?
- CATALOG TCPIP NODE myhost REMOTE db2srv SERVER 446
- CATALOG TCPIP NODE mydb2srv REMOTE myhost SERVER 446
- CATALOG TCPIP NODE myhost REMOTE db2srv SERVER 192.168.10.1
- CATALOG TCPIP NODE mydb2srv REMOTE myhost SERVER 192.168.10.1
A stored procedure object is created into which DB2 object?
- Alias
- Schema
- Package
- Routine Space
Given the following DDL and INSERT statements: CREATE VIEW v1 AS SELECT col1 FROM t1 WHERE col1 > 10; CREATE VIEW v2 AS SELECT col1 FROM v1 WITH CASCADED CHECK OPTION; CREATE VIEW v3 AS SELECT col1 FROM v2 WHERE col1 < 100; INSERT INTO v1 VALUES(5); INSERT INTO v2 VALUES(5); INSERT INTO v3 VALUES(20); INSERT INTO v3 VALUES(100); How many of these INSERT statements will be successful? What is the expected sequence of value returned from the below query? SELECT Product-ID, Quantity from Customer ORDER BY Product-ID;
- 0
- 1
- 2
- 3
Which of the following is not true about XML Columns ?
- Data can be retrieved by SQL
- Data can be retrieved by XQUERY
- XML Columns must be altered to accommodate additional parent and child relationships
- Access to any portion of an XML document can be direct ,without reading whole document
An application needs to store a 5MB JPEG image in a DB2 table. Which datatype should be used to specify a column that will be used for storing A image ?
- GRAPHIC
- BINARY
- IMAGE
- BLOB
Which of the following constraint types can be used to ensure the value Of an INTEGER column references only positive values.
- Unique
- Check
- Referential
- Informational
Given that tables T1 and T2 contain the following rows : Table T1 : C1 C2 (5 4) (5 2) (5 5) Table T2 : C1 C2 (5 1) (5 2) (5 3) Which of the following queries will return only those rows that exists in T1 and not in T2 ?
- Select * from T1 minus select * from T2
- Select * from T1 except select * from T2
- Select * from T1 union except select * from T2
- Select * from T1 not exists select * from T2