• USA : +1 973 910 5725
  • INDIA: +91 905 291 3388
  • info@tekslate.com
  • Login

IBM DB2 Interview Questions

What is DB2 ( IBM Database 2 )?

DB2 is subsystem of the MVS operating system. It is a Database Management System ( DBMS ) for that operating system.

What is an access path?

The path that is used to get to data specified in SQL statements.

What is an alias?

It is an alternate name that can be used in SQL statements to refer to a table or view in the same or remote DB2 subsystem

Explain what a plan?

Plan is a DB2 object (produced during the bind process ) that associates one or more database request modules with a plan name.

What is a DB2 bind?

Bind is a process that builds “access paths ” to DB2 tables. A bind uses the Database Request Modules (s) (DBRM (s)) from the DB2 precompile step as input and produces an application plan. It also checks the user’s authority and validates the SQL statements in DBRM(s).

What information is used as input to the bind process?

The database request module produced during the pre-compile. The SYSIBM.SYSSTMT table of the DB2 catalog.

What is meant by the attachment facility?

The attachment facility is an interface between DB2 and TSO, IMS/VS, CICS, or batch address spaces. It allows application programs to access DB2.

What is meant by AUTO COMMIT

AUTO COMMIT is a SPUFI option that commits the effects of SQL statements automatically if they are successfully executed.

What is a base table ?

A base table is real table – a table that physically exists in that there are physical stored records.

What is the function of buffer manager ?

The buffer manager is the DB2 component responsible for physically transferring data betwwen an external medium and (virtual) storage (perform the actual I/O operations ). It minimizes the amount of physical I/O actually performed with sophisticated buffering techniques (i. e. read – ahead buffering and look-aside buffering ).

What is a buffer pool ?

A buffer pool is main storage that is reserved to satisfy the buffering requirements for one or more tablespaces or indexes, and is made up of either 4K or 32K pages.

How many buffer pools are there in DB2?

There are four buffer pools: BP0, BP1, BP2, and BP32.

On the create tablespace, what does the CLOSE parameter do?

CLOSE physically closes the tablespace when no one is working on the object. DB2 (release 2.3 ) will logically close tablespaces.

What is a clustering index?

It is a type of index that (1) locates table rows and (2) determines how rows are grouped together in the tablespace.

What will the COMMIT accomplish?

COMMIT will allow data changes to be permanent. This then permits the data to be accessed by other units of work. When a COMMIT occurs, locks are freed so other applications can reference the just committed data.

What is meant by concurrency?

Concurrency is what allows more than one DB2 application process to access the same data at essential the same time. Problems may occur, such as lost updates, access to uncommitted data, and unrepeatable reads.

What is cursor stability?

It is cursor stability that “tells” DB2 that database values read by this application are protected only while they are being used. (Changed values are protected until this application reaches the commit point ). As soon as program moves from one row to another. Other programs may read or the first row.

What is the function of the Data Manager?

The Data Manager is a DB2 component that manager the physical databases. It invokes other system components, as necessary, to perform detail function such as locking, logging, and physical I/O operations ( such as search, retrieval, update, and index maintenance).

What is a Database Request Module (DBRM)?

A DBRM is a DB2 component created by the DB2 precompiler containing the SQL source statement extracted from the application program. DBRMs are input to the bind process.

What is a data page?

A data page is a unit of retrievable data, either 4K or 32K ( depending on how the table is defined ), containing user or catalog information.

What is Declaration Generator ( DCLGEN )?

DCLGEN is a facility that is used to generate SQL statements that describe a table or view. These table or view descriptions are then used to check the validity of other SQL statements at precompile time. The table or view declares are used by the DB2I utility DCLGEN to build a host language structure, which is used by the DB2 precompiler to verify that correct column names and data types have been specified in the SQL statement.

What will the FREE command do to a plan?

It will drop ( delete ) that existing plan.

What is a host variable?

This is a data item that is used in an SQL statement to receive a value or to supply a value. It must be preceded by colon (:) to tell DB2 that the variable is not a column name.

What will the DB2 optimizer do?

The optimizer is a a DB2 component that processes SQL statements and selects the access paths.

What is a page?

This is the unit of storage within a tablespace or index space that is accessed by DB2.

What is page space?

Page Space refers to either to an unpartitioned table, to an index space, or to a single partition of a partitioned table of index space.

What is a predicate?

A predicate is an element of a search condition that expresses or implies a comparison operation.

What is a recovery log?

A recovery log is a collection of records that describes the sequence of events that occur in DB2. The information is needed for recovery in the event of a failure during execution.

What is a Resource Control Table (RCT)? Describe its characteristics.

The RCT is a table that is defined to a DB2/CICS region. It contains control characteristics which are assembled via the DSN CRCT macros. The RCT matches the CICS transaction ID to its associated DB2 authorization ID and plan ID ( CICS attachment facility).

Where are plans stored ?

Each plan is defined uniquely in the SYSIBM SYSPLANS table to correspond to the transaction(s) that are to execute that plan.

What is meant by repeatable read?

When an application program executes with repeatable read protection, rows referenced by the program can’t be changed by other programs until the program reaches a commit point.

Describe what a storage group (STOGROUP) is?

A STOGROUP is a named collection of DASD volumnes to be used by table spaces and index spaces of databases. The volumns of STOGROUP must be of the same device type.

How would you move a tablespace ( using STOGROUP ) to a different DASD volume allocated to that tablespace?

If the tablespace used is only allocated do that STOGROUP :

ALTER STOGROUP- add volume (new ) delete volume (old )


Create a new STOGROUP that points to the new volume. ALTER the tablespace and REORG or RECOVER the tablespace.

What is the format (internal layout) of “TIMESTAMP”?

This is a seven part value that consists of a date (yymmdd) and time (hhmmss and microseconds)

What is meant by a unit of recovery?

This is a sequence of operations within a unit of work (i. e. , work done between commit points).

Can DB2 be accessed by TSO users? If yes, which command is used to invoke DB2

DB2 can be invoked by TSO users by using the DSN RUN command.

What is a DB2 catalog ?

The DB2 catalog is a set of tables that contain information about all of the DB2 objects ( tables, views, plans etc ).

What information is held in SYSIBM.SYSCOPY?

The SYSIBM.SYSCOPY table contains information about image copies made of the tablespaces.

What information is contained in a SYSCOPY entry?

Included is the name of the database, the table space name, and the image copy type (full or incremental etc..) as well as the date and time each copy was made.

What information can you find in SYSIBM.SYSLINKS table?

The SYSIBM.SYSLINKS table contains information about the links between tables created by referential constraints.

Where could you look if you had a question about whether a column has been defined as an index?

This information can be found in SYSIBM.SYSINDEXES.

What is the SQL Communications Area and what are some of its key fields?

It is a data structure that must be included in any host-language program using SQL. It is used to pass feedback about the SQL operations to the program. Fields are return codes, error messages, handling codes and warnings.

What is DCLGEN?

DCLGEN stands for declarations generator, it is a facility to generate DB2 SQL data structure in COBOL or PL/I programs.

How do you leave the cursor open after issuing a COMMIT? (for DB2 2.3 or above only )?

Use WITH HOLD option in DECLARE CURSOR statement. But, it has not effect in pseudo-conversational CICS programs.

What is the physical storage length of each of the following DB2 data types : DATE, TIME, TIMESTAMP?

DATE: 4 bytes
TIME: 3 bytes
TIMESTAMP: 10 bytes

What is DCLGEN?

DeClarations GENerator: used to create the host language copy books for the table definitions. Also creates the DECLARE table.

Is it mandatory to use DCLGEN? If not, why would you use it at all ?

It is not mandatory to use DCLGEN. Using DCLGEN, helps detect wrongly spelt column names etc. during the pre-compile stage itself ( because of the DECLARE TABLE ). DCLGEN being a tool, would generate accurate host variable definitions for the table reducing chances of error.

Is DECLARE TABLE in DCLGEN necessary? Why it used?

It not necessary to have DECLARE TABLE statement in DCLGEN. This is used by the pre-compiler to validate the table-name, view-name, column name etc.., during pre-compile.

How is a typical DB2 batch program executed?

There are two methods of executing a DB2 – batch program

Use DSN utility to run a DB2 batch program from native TSO. An example is shown:

Use IKJEFT01 utility program to run the above DSN command in a JCL.

Name some of field from SQLCA?


What is EXPLAIN?

EXPLAIN is used to display the access path as determined by the optimizer for a SQL statement. It can be used in SPUFI (for single SQL statement ) or in BIND step ( for embedded SQL). The results of EXPLAIN is stored in U.PLAN_TABLE where U is the authorization id of the user.

What do you need to do before you do EXPLAIN?

Make sure that the PLAN_TABLE is created under the AUTHID.

Where is the output of EXPLAN stored?


How do you do the EXPLAIN of a dynamic SQL statement ?

There are two methods to achieve this:

Use SPUFI or QMF to EXPLAIN the dynamic SQL statement

Include EXPLAIN command in the embedded by dynamic SQL statements

How do you simulate the EXPLAIN of an embedded SQL statement in SPUFI/QMF ? Give an example with a host variable in where clause) ?

Use a question mark in place of a host variable (or an unknown value). For instance,

What are the isolation levels possible ?

CS: Cursor Stability

RR: Repeatable Read

What is the difference between CS and RR isolation levels ?

CS: Release the lock on a page after use

RR: Retains all locks acquired till end of transaction

When do you specify the isolation level? How ?

During the BIND process (ISOLATION LEVEL is a parameter for the bind process ).

How does DB2 determine what lock-size to use?

There are three methods to determine the lock-size. They are;

-Based on the lock-size given while creating the tablespace.

-Programming can direct the DB2 what lock-size to use

-If lock-size ANY is specified, DB2 usually chooses a lock-size of PAGE

What is lock escalation?

Promoting a PAGE lock-size to table or tablespace lock-size when a transaction has acquired more lock than specified in NUMLKTS. Locks should be taken on objects in single tablespace for escalation to occur.

What are the various locks available?


What is ALTER?

SQL command used to change the definition of DB2 objects.

What is a DBRM, PLAN?

DBRM: Data Base Request Module, has the SQL statements extracted from the host language program by the pre-compiler.
PLAN: A result of the BIND process. It has the executable code for the SQL statements in the DBRM.


Determine the point at which DB2 acquires or releases locks against table and tablespaces, including intent locks.

What else is there in the PLAN apart from the access path?

PLAN has the executable code for the SQL statements in the host program

What happens to the PLAN if index used by it is dropped?

Plan is marked as invalid. The next time the plan is accessed, it is rebound.

What are PACKAGES?

They contain executable code for SQL statements for one DBRM.

What are the advantages of using a PACKAGE?

The advantages of using PACKAGE are :

Avoid having to bind a large number of DBRM members into a plan

Avoid cost of a large bind

Avoid the entire transaction being unavailable during bind and automatic rebind of a plan

Minimize fallback complexities if changes result in an error.

What is a collection?

A user defined name that is the anchor for packages. It has not physical existence. Main usage is to group packages.

How would you print the output of an SQL statement from SPUFI?

Print the output dataset.

What is dynamic SQL?

Dynamic SQL is a SQL statement created at program execution time.

When is the access path determined for dynamic SQL?

At run time, when the PREPARE statement is issued.

Suppose I have a program which uses a dynamic SQL and it has been performing well till now. Off late, I find that performance has deteriorated. What happened?

There may be one of the following reasons:

probably RUN STATS is not done and the program is using a wrong index due to incorrect stats.

probably RUN STATS is done and optimizer has chosen a wrong access path based on the latest statistics.

How does DB2 store NULL physically?

As an extra-byte prefix to the column value. Physically, the null prefix is Hex ’00” if the value is present and Hex ‘FF’ if it is not.

How do you retrieve the data from a nullable column?

Use null indicators. Syntax .. INTO: HOSTVAR:NULLIND

What is the picture clause of the null indicator variable?

S9(4) COMP.

What does it mean if the null indicator has -1, 0, -2??

-1 : the field is null;
0 : the field is not null;
-2: the field value is truncated

How do you insert a record with a nullable column?

To insert a NULL, move -1 to the null indicator. To insert a valid value, move 0 to the null indicator


A DB2 utility used to collect statistics about the data value in tables which can be used by the optimizer to decide the access path. It also collects statistics used for space management. These statistics are stored in DB2 catalog tables.

When will you chose to run RUNSTATS?

After a load, or after mass updates, inserts, deletes, or after REORG.

Review Date
Reviewed Item
IBM DB2 Interview Questions
Author Rating

“At TekSlate, we are trying to create high quality tutorials and articles, if you think any information is incorrect or want to add anything to the article, please feel free to get in touch with us at info@tekslate.com, we will update the article in 24 hours.”

0 Responses on IBM DB2 Interview Questions"

Leave a Message

Your email address will not be published. Required fields are marked *

Site Disclaimer, Copyright © 2016 - All Rights Reserved.