Top DB2 Interview Questions And Answers
Here are top 34 objective type sample DB2 Interview questions and their answers are given just below to them. These sample questions are framed by experts from Intellipaat who trains for DB2 Training
to give you an idea of type of questions which may be asked in interview. We have taken full care to give correct answers for all the questions. Do comment your thoughts Happy Job Hunting!
Wish to Learn DB2? Click Here
Top Answers to DB2 Interview Questions
1.How to find number of rows in DB2 tables?
User has to use SELECT COUNT (*) on DB2 query.
2.How can duplicate values be eliminated from DB2 SELECT?
To eliminate duplicate values in DB2 SELECT, the user has to use SELECT DISTINCT in DB2 query.
3.What is meant by aggregate function?
‘Aggregate’ functions are built in mathematical tools that are used in DB2 SELECT clause.
4.Is it possible using MAX on a CHAR column?
Yes! It is possible using the MAX on a CHAR column.
5.What is the reason that MySQL statement “SELECT AVG (SALARY) FROM EMP” generates inaccurate output?
The reason for the statement generating inaccurate outcome is because of the fact that SALARY has not been declared to have NULL and at the same time the employees whose salary is not known are also counted.
Wish to Learn DB2? Click Here
6.How can the FIRSTNAME and the LASTNAME from the EMP table concatenated to generate complete names?
Statement to concatenate the first and last name to display the full name is FIRSTNAME II ** II LASTNAME FROM EMP.
7.How the value function is used?
Two tasks are accomplished by the ‘Value’ function. The first one is avoiding –veSQLCODEs through the handling of NULLs as well as Zeroes in the computation. The second one is substituting numeric values for nulls used in computation.
8.What is UNION and UNION ALL?
UNION is the function that eliminates duplicates in the table and UNION ALL retains the duplicates. Both of these are used to combine the results generated by multiple SELECT statements.
9.Is there any restriction on its use in embedded SQL?
While using UNION in embedded SQL it has to be in a CURSOR.
10.What are meant by BETWEEN and IN and is BETWEEN inclusive of range values that are specified?
BETWEEN would supply a range of values whereas IN would provide list of values. BETWEEN is always inclusive of the range values specified.
11.When the LIKE statement is used?
LIKE statement is used to conduct partial searches like the search of employees by name. It is not necessary to indicate the complete name, the partial string matches would do.
12.Why SELECT is not preferred in embedded SQL programs?
SELECT is not preferred in embedded SQL programs for three reasons. First; if the table structure is changed by addition or deletion of a field and the program is modified then using SELECT might retrieve the columns that the user may not use. This would lead to Input Output overhead and the chances of index only scan is also eliminated.
13.What is a CURSOR and what is its use?
A CURSOR is programming device that helps the SELECT to find out set of rows but displays them one at a time. Since the host language can deal with only one row at a time.
14.How to retrieve rows from a DB2 table in embedded SQL?
Rows form DB2 table embedded SQL can be retrieved using the single row SELECT statement. Another way is using the CURSOR. However, the first process is the preferred one.
15.What is the result of OPEN CURSOR statement?
In simple OPEN CURSOR statement the CURSOR is placed on the first row of the table. On the other hand, if the ORDER BY clause is added, rows would be fetched, sorted and would be available for the FETCH statement.
16.Can there be more than one cursor open for any program?
Yes! The user can have more than one cursor open for any program.
17.How would the VARCHAR column REMARKS defined?
The VARCHAR column remarks would be defined as follows.10 REMARKS.49 REMARKS-LEN PIC S9(4) USAGE COMP.49 REMARKS-TEXT PIC X(1920).
18.What is the physical storage length of the data types DATE, TIME, and TIMESTAMP?
The physical storage length of DATE is 4 bytes, TIME is 3 bytes, and TIMESTAMP is 10 bytes.
19.What is meant by DCLGEN?
DCLGEN refers to DeClarations GENerator that is used to create the host language copy books for the table definitions. It also creates the DECLARE table.
20.What are the contents of DCLGEN?
The contents of DCLGEN are EXEC SQL DECLARE TABLE statement that gives the layout of the table/view in terms of the DB2 data types. It can also be defined as the host language copy book giving host variable definitions for the column names.
21.What are some of the main fields in SQLCA?
Major Fields in SQLCA is SQL CODE, SQLERRM, and SQLERRD.
22.What is meant by EXPLAIN?
Use of EXPLAIN is for displaying the access path as determined by the optimizer for SQL statement. It can also be used in case of SPUFI for single SQL statements or in the BIND step for embedded SQL.
23.How to do the EXPLAIN of any dynamic SQL statement?
User can use SPUFI or QMF statements to EXPLAIN the dynamic SQL statement. They can also include EXPLAIN command in the embedded dynamic SQL statements.
24.What are the isolation levels possible?
Two isolation levels are possible. One is CURSOR stability and the other one is Repeatable Read denoted as CS and RR respectively.
25.What is the difference between the CS and RR isolation levels?
CS would release the lock on the page after its use. RR would retain all the locks acquired till the end of the transaction.
26.What is meant by lock escalation?
Lock escalation is the process of promoting PAGE lock sizes to table or table space lock size when the transaction has acquired more locks than the ones specified in NUMLKTS. Locks have to be taken on objects in single table space for escalations to take place.
27.What are the various types of locks?
There are three different types of locks such as SHARE, EXCLUSIVE, and UPDATE.
28.What is ALTER?
ALTER is the SQL command to change the definition of DB2 objects.
29.What is a DBRM, PLAN?
DBRM denotes Data Base Request Module. It has the SQL statements that are extracted from the host language program obtained by the pre-compiler. PLAN is the result of the BIND process and has executable code for SQL statements in DBRM.
30.What is meant by ACQUIRE/RELEASE in BIND?
ACQUIRE/RELEASE in BIND determines the point at which the DB2 either acquires or releases locks against the table and the table spaces. This includes the intent locks.
31.What is meant by PACKAGES?
PACKAGES contain executable codes for SQL statements in respect of one DBRM.
32.What are the advantages of using PACKAGES?
When used, PACKAGES help avoiding the binding of large numbers of DBRM members in one plan. It also dispenses with the cost of large BIND and avoids the entire transactions making them unavailable during BIND and automatic REBIND of the plan. Another advantage is that it minimizes the fallback complexities when changes result in an error.
33.What is a collection?
A collection is the user defined name that works as the anchor for packages but has no physical existence. The use is for grouping of packages.
34.What is dynamic SQL?
Dynamic SQL is the SQL statement created at the time of execution of a program.