DB2 interview question set 2/DB2 Interview Questions and Answers for Freshers & Experienced

Mention the definition of COBOL in VARCHAR field.

The REMARKS of VARCHAR column are as follows: –



49 REMARKS – TEXT PIC X (1920).



49 REMARKS – TEXT PIC X (1920).

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 the 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 an index-only scan are also eliminated.

When will you choose to run RUNSTATS?

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

What is the reason that the MySQL statement “SELECT AVG (SALARY) FROM EMP” generates inaccurate output? The reason for the statement generating inaccurate outcomes 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.

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

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 retrieve the data from a nullable column?

Use null indicators. Syntax .. INTO HOSTVAR: NULLED

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.

Suppose I have a program that 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 the optimizer has chosen a wrong access path based on the latest statistics.

When is the access path determined for dynamic SQL?

At run time, when the PREPARE statement is issued.

What is a collection?

A user-defined name that is the anchor for packages. It has no physical existence. The main usage is to group packages.

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 the 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 else is there Ain the PLN apart from the access path?

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

What is a DBRM, PLAN?

DBRM: DataBase 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.

What is ALTER?

SQL command used to change the definition of DB2 objects.

What is lock escalation?

Promoting a PAGE lock-size to the 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.

How does DB2 determine what lock-size to use?

There are three methods to determine 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

When do you specify the isolation level? How?

During the BIND process (ISOLATION LEVEL is a parameter for the binding process ). ISOLATION (CS/PR)..

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 the end of the transaction

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 leave the cursor open after issuing a COMMIT?

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

What Is Join And Different Types Of Join?

The ability to join rows and combaine data from two or more tables is one of the most powerful features of relational system.Three type of joins:

1. Equi-join
2. Non-equijoin
3. self-join.

B37 Abend During Spufi?

The b37 abend in the spufi is because of space requirements , the query has resulted in so many rows that the spufi.out file is not large enough to handle it, increase the space allocation of spufi.out file.

When Can You Be Sure That A Query Will Return Only One Row?

When you use the primary key and only the primary key in the where clause.

What Is The Difference Between Join And Union?

join is used to retrive data from different tables using a single sql statement.union is used to combine the results of two or more sql querries.

What Is A Corelated Subquerry?

In a subquerry, if the outer querry reffers back to the outcome of innerquerry it is called corelated subquerry. That's why the outer querry is evaluated first unlike an ordinary subquerry.

What Are The Functions Of Bind?

BIND mainly performs two things syntax checking and authorization checking.It binds together all packages into an application plan hence the name BIND.Apart from this bind has optimiser as a subcomponent.Its function is to determine the optimum access strategy.

What's The Best Locksize That You Could Use When You Create A Tablespace?

The answer is Locksize = ANY.Unless you are Sure what's the Purpose of tablespace ie.,Read-only or R/W.If you use lock size =any, Db2 would automatically determine what type of locks it should use.

What Does Currentdata Option In Bind Indicate?

CURRENTDATA option ensures block fetch while selecting rows from a table. In DB2V4 the default has been changed to NO. Therefore it is necessary to change all the bind cards with CURRENTDATA(YES) which is default in DB2V3 & earlier to CURRENTDATA(NO).

What Is The Difference Between Type 1 Index & Type 2 Index?

TYPE 1 & TYPE 2 are specified when an index is created on the table. TYPE 2 index is the option which comes with DB2V4. With TYPE 2 index data can be retreived faster as only the data pages are locked and not the index pages. Hence TYPE 2 index is recommended.

What Are The Levels Of Isolation Available With Db2v4?

CS RR UR( added new for DB2V4 which stands for uncommited read which allows to retreive records from the space which has exclusive locks also but data integrity will be affected if this option is used )The best available option for data integrity & data concurrency is CS.

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.

Once You Create A View, Where Would Information About The View Be Stored?

When a view is created, system information about the view is stored in SYSIBM.SYSVIEWS.

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.

What information is contained in an SYSCOPY entry?

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

What information is held in SYSIBM.SYSCOPY?

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

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)

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 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.

What is a predicate?

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

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 a colon (:) to tell DB2 that the variable is not a column name.

What is the function of the Data Manager?

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

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 UNION and UNION ALL?

UNION – It is the function that eliminates duplicates from the table.
UNION ALL – It is the function used to retain the duplicates in the table.
Both the functions are used to combine the results generated by multiple SELECT statements.


There is a certain point in a program at which DB2 acquires or perhaps releases the locks against tables as well as table-spaces. These include intent locks.

What is meant by EXPLAIN?

EXPLAIN is basically used to show the path of access by the optimizer basically for an SQL statement. Furthermore, EXPLAIN can also be brought to use in SPUFI or even in BIND step.

In case if at some point of time DB2 is down, would that impact the pre-compilation process of a DB2-COBOL program?

Even if DB2 is down at some point of time, even then it will not impact the pre-compilation process of DB2-COBOL program. The reason for the same is that the pre-compiler never refers to the catalogue tables of DB2.

Explain the contents that are a part of DCLGEN.

There are primarily two components of DCLGEN. These are: –

A copy book of the host language, which will give alternative definitions for all the column names.
In terms of the data-types of DB2, EXEC SQL DECLARE TABLE shows an aesthetic layout of the table.


PACKAGES are units, which consist of executable codes that are meant for SQL statements for one respective DBRM.

R4R Team
R4R provides DB2 Freshers questions and answers (DB2 Interview Questions and Answers) .The questions on R4R.in website is done by expert team! Mock Tests and Practice Papers for prepare yourself.. Mock Tests, Practice Papers,DB2 interview question set 2,DB2 Freshers & Experienced Interview Questions and Answers,DB2 Objetive choice questions and answers,DB2 Multiple choice questions and answers,DB2 objective, DB2 questions , DB2 answers,DB2 MCQs questions and answers Java, C ,C++, ASP, ASP.net C# ,Struts ,Questions & Answer, Struts2, Ajax, Hibernate, Swing ,JSP , Servlet, J2EE ,Core Java ,Stping, VC++, HTML, DHTML, JAVASCRIPT, VB ,CSS, interview ,questions, and answers, for,experienced, and fresher R4r provides Python,General knowledge(GK),Computer,PHP,SQL,Java,JSP,Android,CSS,Hibernate,Servlets,Spring etc Interview tips for Freshers and Experienced for DB2 fresher interview questions ,DB2 Experienced interview questions,DB2 fresher interview questions and answers ,DB2 Experienced interview questions and answers,tricky DB2 queries for interview pdf,complex DB2 for practice with answers,DB2 for practice with answers You can search job and get offer latters by studing r4r.in .learn in easy ways .