Online IDE
Free Mock
Events New Scaler
Improve your coding skills with our resources
Compete in popular contests with top coders
Attend free live masterclass hosted by top tech professionals
Explore Offerings by SCALER

Download Interview guide PDF

Before you leave, take this DB2 Interview Questions interview guide with you.
Get a Free Personalized Career Roadmap
Answer 4 simple questions about you and get a path to a lucrative career
expand-icon Expand in New Tab
/ Interview Guides / DB2 Interview Questions

DB2 Interview Questions

Last Updated: Jan 02, 2024

Download PDF

Your requested download is ready!
Click here to download.
Certificate included
About the Speaker
What will you Learn?
Register Now


DB2 database is a very popular relational database. Many companies working around DB2 ask questions based on extensive knowledge of it in their interviews both from the freshers as well as from experienced candidates. In this article, we are going to learn about some of the most famous DB2 interview questions.

What is a Database?

A database is a collection of logically related (or simply inter-related) data. For example, a database of a school will contain data about the faculty members such as their name, Employee ID, Date of Joining, Leaves Taken so far in the current year, Classes which the teacher is teaching, and so on. It will also contain the data of students like the Enrollment Number of the student, name of the student, age and parent’s name, etc.

What is a Relational Database?

A relational database is such a database in which the data is arranged in the form of tables i.e. rows (known as tuples) and columns (known as attributes). For example, a student database, which shows the details of students in a school is shown below:

The above table is an example of a relational database where the data is arranged in the form of rows and columns. Some of the famous relational databases are MySQL, DB2, PostgreSQL, etc.

What is DB2?

DB2 in general is a family of data management products. It is developed by IBM. The AI-powered family of data management tools helps us in the management of both structured as well as unstructured data. The DB2 relational database is a relational database that is part of the DB2 family of data management tools. 

So, now we are going to discuss the most important questions asked in interviews. We have divided the questions into two sections. The first section is going to be the basic section where we will discuss the questions that are basic in level and also have a high probability of appearing in the interviews for a fresher and the other section consists of advanced questions for experienced candidates.

DB2 Interview Questions for Freshers

1. How is INNER JOIN different from simply writing a JOIN?

If we do not specify the type of join, by default, the join is an INNER JOIN. So, there is no difference between writing INNER JOIN or simply writing JOIN.

Now that we have seen some of the most popular interview questions of DB2 for freshers, let us move to some intermediate and advanced questions too that are asked in the interviews from an experienced candidate.

Create a free personalised study plan Create a FREE custom study plan
Get into your dream companies with expert guidance
Get into your dream companies with expert..
Real-Life Problems
Prep for Target Roles
Custom Plan Duration
Flexible Plans

2. Explain DB2.

DB2 is a family of data management tools developed by IBM. However, if we specifically talk about the databases, DB2 is a relational database that was released in 1989 by IBM. DB2 was written using many programming languages that include C, C++, Java, and even Assembly Language. It has an operating system that works on Linux and Windows.

3. What is DCLGEN in DB2?

DCLGEN stands for Declarations generator. The programs that we write should declare the tables and views that it accesses. The declarations generator i.e. DCLGEN produces these DECLARE statements for C, Cobol and PL/I programs so that one does not need to code the statements manually. It also generates corresponding host variable structures. When DCLGEN is used to generate a table declaration, the DB2 uses the DB2 catalog to get the relevant information from it. DCLGEN, then uses this information to create an SQL DECLARE TABLE statement for the table/view.

You can download a PDF version of Db2 Interview Questions.

Download PDF

Your requested download is ready!
Click here to download.

4. As you know there are different sizes of locks. Can you tell how DB2 decides which lock size should be used?

The lock size is determined by three methods. These methods are:

  • The lock size can be decided based on the lock size given while creating a new TABLESPACE.
  • Also, Programming directs DB2 about the lock size.
  • If the lock size ANY is specified, then DB2 (in most of the cases) chooses the lock size of PAGE.

5. What are the two levels of isolation and what is the major difference between the 2 levels?

The two levels of isolation are Cursor Stability (CS) and Repeatable Read (RR). The major difference between these 2 levels is that the Cursor Stability (CS) releases the lock on a page after the use whereas the Repeatable Read (RR) retains all the locks till the end of a transaction.

Learn via our Video Courses

6. How can you move a tablespace to a different DASD volume allocated to that tablespace if you have to use STOGROUP?

The method to move the tablespace to a different DASD volume allocated to that tablespace is:



So, basically, the method is that we create a new STOGROUP that points to the new volume and ALTER the tablespace and REORG or RECOVER the tablespace.

7. What is MAX in DB2? Is it possible to use MAX in a CHAR column?

MAX() is an aggregate function that returns the maximum value from a set of values. For example, if we have a database of movies, we can apply MAX(rating) on the rating attribute and it will select the rows in which we have the movies with the highest ratings. Yes, MAX can be used on a CHAR column.

Advance your career with   Mock Assessments Refine your coding skills with Mock Assessments
Real-world coding challenges for top company interviews
Real-world coding challenges for top companies
Real-Life Problems
Detailed reports

8. What is a CURSOR and What is the use of it?

CURSOR is a programming device that is used to find a set of rows corresponding to a SELECT statement. However, the rows are displayed one at a time.

9. What is concurrency in terms of DB2?

Concurrency means that more than one application process of DB2 can access the data at the same time. Concurrency can cause some issues like lost updates, access to unrepeatable reads and uncommitted data.

10. What are UNION and UNION ALL in DB2? How do you differentiate between them?

The union command is used to merge 2 or more SELECT statements and the select statements can be applied on a single table as well as on multiple tables. The major difference between UNION and UNION ALL is that UNION removes the duplicate rows when it is applied on the tables whereas UNION ALL retains the duplicates. 

11. What is the difference between the above two queries i.e. DELETE and DROP?

The DELETE * FROM table-name query deletes all the rows from the table but, there is still an empty table with no rows and no columns in the database. However, the DROP TABLE table-name query deletes all the rows and columns and along with that, the table gets deleted from the database too i.e. the table is completely removed (deleted) from the database. 

12. Write a query to delete the entire table from the database in DB2.

The query to delete the entire table from the database is given below:

DROP TABLE table-name

13. Write a query to delete all the rows from a table in DB2.

The query to delete all the rows from a table in DB2 is:

DELETE * FROM table-name

14. Write a Query to find the number of rows in a DB2 table.

Here, the interviewer might ask you to write down the query on a piece of paper or a google doc or any other method. Mostly, the interviewers do not ask you to write a query upon a pre-existing table. 

The query is:


15. What is the difference between CHAR and VARCHAR?

As the name suggests, the main difference is that CHAR is of fixed length whereas VARCHAR is of variable length. This means that char always has a fixed length to store the text whereas the VARCHAR adjusts its length according to the length of the text and this helps in saving the memory. Also, the CHAR data type can have a maximum size of 254 bytes whereas VARCHAR can have a maximum size of 4046 bytes.

16. What is the difference between SMALLINT and INTEGER?

The difference is in the range and precision. While the SMALLINT can store the numbers up to a precision of 15 bits with a range of -32768 to +32767, the INTEGER data type can store the numbers up to a precision of 31 bits having the range from -2,147,483,648 to +2147483648. There is also one more data type to store the integer type of data. It is called BIGINT and its range is even higher than INTEGER.

17. What are the different data types available in DB2?

There is a total of 8 data types in DB2. They are SMALLINT, INTEGER, FLOAT, DECIMAL, CHAR, VARCHAR, DATE, and TIME.

DB2 Interview Questions for Experienced

1. How will you achieve record level locking in DB2 versions where record level locking is not allowed?

We can achieve the record level locking in DB2 versions where the record level locking is not allowed by having the length of the record greater than that of a page itself.

Now that we have so much knowledge from the questions that we have studied, let us now move to practice some of the MCQs that will help test your knowledge too.

Useful Interview Resources

2. What is DSNDB07? What does it do?

DSNDB07 is a database where the DB2 performs its sorting operations. It includes the sort work-area of DB2 and external storage. 

3. Is there any specific reason why SELECT is not preferred in embedded SQL programs?

The SELECT statement is not preferred in embedded SQL programs for 3 reasons:

  • If there is a change in the structure of the table by addition or deletion of a field, the program gets modified and using the SELECT statement might retrieve those columns that the user may not even use.
  • The use of SELECT in the embedded SQL programs can lead t the input-output overhead and,
  • The chances of an index-only scan are eliminated by the use of SELECT in embedded SQL programs. 

4. What is the RUN STATS that was mentioned in the previous answer?

RUN STATS is a DB2 utility used to collect statistics about the data value in TABLES. It is used by the optimizer to decide the access path. RUN STATS also collects statistics that are used for space management. These statistics are stored in the DB2 catalog tables.

Usually, the RUN STATS is run after the following:

  • After a load.
  • After a mass update.
  • After any major deletions, insertions, or
  • After REORG the table.

5. Let us say that I have a program it uses dynamic SQL. It has been working fine till now, however, lately, I have found that the performance has been affected and deteriorated. Can you guess what can be the reason behind this?

There can be 2 possibilities:

  • RUN STATS is not done and it seems that the program is using an incorrect/wrong index due to incorrect/wrong stats.
  • It might also be the case that the RUN STATS has been done but the optimizer has chosen a wrong access path based on the latest statistics.

6. What are SPUFI and QMF? What is the difference between them?

  • SPUFI: SPUFI is an execution engine for SQL where the SQL commands are executed. Several SQL queries can be executed at once and the result of the queries can be stored in PS or PDS members. Also, the SQL is known to us even after the execution of the query.
  • QMF: It is a reporting environment and supports the formatting of reports. More than one query cannot be executed and the result of the query cannot be persisted. Also, the SQL code of the query cannot be known. 

7. In a COBOL-DB2 program, where are all the SQL statements coded?

In a COBOL-DB2 program, all the statements are coded in Area B.

8. What are ACQUIRE and RELEASE in BIND?

A certain point in a program when DB2 acquires or releases the locks against the tables and/or tablespaces. These include the intent locks as well.

9. Let us say that we have a Student Database in which we have the details of the students like their names, address, attendance percentage, etc. Now we run an SQL Query that says: SELECT AVG ATTENDANCE FROM STUDENTS.

Can you tell me any issues that may be here?

Yes, there might be an issue. For instance, if there is such a case where we have set that the attendance of any student cannot be null and at the same time we have some students in the table whose attendance we don’t know, the AVG function will calculate these students as well. Hence, we will get an answer but, it might not be correct.

10. Is it possible for you to alter the table (adding a column to it) while some other person is accessing the table and even updating some values in it?

To be short and crisp, the answer is yes, we can alter the table at the same time when some other transaction is taking place but this does not exactly happen as it sounds to be.

The DB2 table will not change its structure in any form till a transaction or multiple transactions are taking place. The table-altering commands will be stored by the database engine and will not be executed till all the transactions are complete. After one user has modified the values in the table, then the column will be added.

11. What is the maximum length of SQLCA?

The maximum length of SQLCA is 136.

12. Do you know any programming language where more than one SQLCA is used?

Yes, FORTRAN applications require more than one SQLCA.

13. How many SQLCA must be provided to an application that contains SQL statements (executable)?

Only one SQLCA is needed for an application that contains executable SQL statements. However, SQLCA is not applicable to Java applications.

14. What is SQLCA?

The full form of SQLCA is the SQL communication area or Structured Query Language Communication Area. It is a structure of variables that is updated after every execution of an SQL statement.

15. Can more than one cursor be opened in a program?

Yes, more than one cursor can be opened in the same program.

DB2 MCQ Questions


How many clustering indices can you define for a single table?


The SQLCA is:


The three statements TRUNCATE, DELETE and DROP perform the same task.


There are 3 types of “Integral” data types in DB2. They are:


There cannot be multiple tables in a DB2 database.


What is the action performed by DB2 when a program executes successfully?


What is the default size of a buffer pool page?


What is the maximum size of the VARCHAR data type in DB2?


Which of the following is true about an INSERT Statement?


Which of the following is TRUE regarding a DB2 table.

Excel at your interview with Masterclasses Know More
Certificate included
What will you Learn?
Free Mock Assessment
Fill up the details for personalised experience.
Phone Number *
OTP will be sent to this number for verification
+91 *
Change Number
Graduation Year *
Graduation Year *
*Enter the expected year of graduation if you're student
Current Employer
Company Name
College you graduated from
College/University Name
Job Title
Job Title
Engineering Leadership
Software Development Engineer (Backend)
Software Development Engineer (Frontend)
Software Development Engineer (Full Stack)
Data Scientist
Android Engineer
iOS Engineer
Devops Engineer
Support Engineer
Research Engineer
Engineering Intern
QA Engineer
Product Manager
Product Designer
Backend Architect
Program Manager
Release Engineer
Security Leadership
Database Administrator
Data Analyst
Data Engineer
Non Coder
Please verify your phone number
Resend OTP
By clicking on Start Test, I agree to be contacted by Scaler in the future.
Already have an account? Log in
Free Mock Assessment
Instructions from Interviewbit
Start Test