IBM DB2 Interview Questions

1. What is DB2?
Answer: DB2 is subsystem of the MVS operating system. It is a Database Management System (DBMS) for that operating system.

2What is meant by repeatable read?
Answer: 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.

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

4What is cursor stability?Answer: 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.

5.What are the advantages of using a PACKAGE?
Answer:

The advantages of using PACKAGE are:

avoid having to bind a large number of DBRM members into a planAvoid 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.

6. On The Create Tables pace, What Does The Close Parameter Do?
Answer: 
CLOSE physically closes the tablespace when no one is working on the object. DB2 (release 2.3) will logically close tablespaces.

7. How is a typical DB2 batch program executed?
Answer: 
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:

  • DSN SYSTEM(DSP3)
  • RUN PROGRAM(EDD 47/0BD) PLAN(EDD470BD) LIB(EDGS01T.OBJ.LOADLIB)

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

8. What is Declaration Generator (DCLGEN)?
Answer: 
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.

9. What will the COMMIT?
Answer: 
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.

10. What Are The Functions Of Bind?
Answer: 
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.

11 .What is meant by a unit of recovery?
Answer: 
This is a sequence of operations within a unit of work (i. e. , work done between commit points).

12. When is the access path determined for dynamic SQL?
Answer: 
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.

13.  What Is Declaration Generator(dclgen)?
Answer: 
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.

 14. What Is Join And Different Types Of Join?
Answer: 
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:

  • Equi-join
  • Non-equijoin
  • self-join.

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

16. What Is A Db2 Catalog?
Answer: 
The DB2 catalog is a set of tables that contain information about all of the DB2 objects(tables, views, plans etc.).

17. How do you do the EXPLAIN of a dynamic SQL statement?
Answer:
 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

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

Answer: 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).

19 .What is the function of the Data Manager?
Answer:
 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).

20.  What Is The Use Of Value Function?
Answer: 
Avoid -ve SQLCODEs by handling nulls and zeroes in computations

Substitute a numeric value for any nulls used in computation

21. What Information Is Contained In A Syscopy Entry?
Answer: 
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.

22. Name The Different Types Of Table Spaces?
Answer: 
1. Simple Table Space 2. Segmented Table Space and 3. Partitioned Table Space.

23. What Is Cursor Stability?
Answer: 
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 a program moves from one row to another, other programs may read or the first row.

24.  What Is A Corelated Subquerry?
Answer: 
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.

25. B37 Abend During Spuf?
Answer: 
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.

26 . What Is The Difference Between Type 1 Index & Type 2 Index?
Answer:
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.

27.  What Is The Function Of Buffer Manager?
Answer: 
The buffer manager is the DB2 component responsible for physically transferring data between an external medium and (virtual) storage (performs 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).

28. What Is A Database Request Module(dbrm?
Answer: 
A DBRM is a DB2 component created by the DB2 pre-compiler containing the SQL source statements extracted from the application program. DBRMs are input to the bind process.

29. How does DB2 determine what lock-size to use?
Answer: 
 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

30. What Is A Resource Control Table(rct)? Describe Its Characteristics?
Answer: 
The RCT is a table that is defined to a DB2/CICS region. It contains control characteristics which are assembled via the DSNCRCT macros. The RCT matches the CICS transaction ID to its associated DB2 authorization ID andplan ID(CICS attachment facility).

31. What Is The Sql Communications Area And What Are Some Of Its Key Fields?
Answer: 
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.

32. What Does Currentdata Option In Bind Indicate?
Answer: 
CURRENT DATA 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(NO0).

33. What Are The Levels Of Isolation Available With Db2v4?
Answer: 
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.

 34. What Is Meant By The Attachment Facility?
Answer: 
The attachment facility is an interface between DB2 and TSO, IMS/VS, CICS, or batch address spaces. It allows application programs to access DB2.

 35. What Will The Commit Accomplish?
Answer: 
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. 

36. What Is Pagespace?
Answer: 
Pagespace refers to either to an unpartitioned table, to an index space, or to a single partition of a partitioned table of index space.

 37. Where Are Plans Stored?
Answer: 
Each plan is defined uniquely in the SYSIBM. SYSPLANS table to correspond to the transaction (s) that are to execute that plan.

38 . Explain The Use Of The Where Clause?
Answer: 
It directs DB2 to extract data from rows where the value of the column is the same as the current value of the host variable.

39.  How Many Subqueries Can You Combine Together?
Answer: 
Total 16 queries and subqueries are 15

40 . How Many Bufferpools Are There In Db2 And What Are They?
Answer: 
There are 4 Bufferpools.They are BP0,BP1,BP2 and BP32.

 41. What Information Can You Find In Sysibm.syslinks Table?
Answer: 
The SYSIBM.SYSLINKS table contains information about the links between tables created by referential constraints.

42.  Once You Create A View, Where Would Information About The View Be Stored?
Answer: 
When a view is created, system information about the view is stored in SYSIBM.SYSVIEWS.

43. What Technique Is Used To Retrieve Data From More Than One Table In A Single Sql Statement?
Answer: 
The Join statement combines data from more that two tables.

 44. What Does Dml Stand For And What Are Some Examples Of It?
Answer: 
Data Manipulation Language. Some examples are SELECT, INSERT, DELETE, REPLACE.

45. What’s The Maximum Number Of Volumes That Can Be Added To A Stogroup?
Answer: 
The answer is 133.Usually it will be difficult monitor more than 3 or 4 volumes to a Stogroup.

46. What’s The Best Locksize That You Could Use When You Create A Tablespace?
Answer: 
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.

47.  What Are The Max. & Min. No. Of Partitions Allowed In A Partition Tablespace?
Answer:
minimum is 4.maximum is 64.

48. What Is The Maximum Number Of Tables That Can Be Joined?
Answer: 
Fifteen.

49.  What Information Is Held In Sysibm.syscopy?
Answer: 
The SYSIBM.SYSCOPY table contains information about image copies made of the tablespaces.

50. What Is A Db2 Catalog?
Answer: 
The DB2 catalog is a set of tables that contain information about all of the DB2 objects(tables, views, plans etc.).

51. How Do You Specify And Use A Cursor In A Cobol Program?            Answer: Use DECLARE CURSOR statement either in working storage or in procedure division(before open cursor), to specify the SELECT statement. Then use OPEN, FETCH rows in a loop and finally CLOSE.

Use DECLARE CURSOR statement either in working storage or in procedure division(before open cursor), to specify the SELECT statement. Then use OPEN, FETCH rows in a loop and finally CLOSE.

52. How Do You Leave The Cursor Open After Issuing A Commit?Answer : Use WITH HOLD option in DECLARE CURSOR statement. But, it has not effect in psuedo-conversational CICS programs.                                       

53. Explain In Detail About Buffer Manager And Its Functionalities?
Answer:
 Buffer manager can be considered as the component inside DB2 that helps in transferring data between virtual as well as external medium. The buffer manager reduces the quantity of physical input as well as output operations that are actually performed by making use of buffering techniques that are highly sophisticated.

54. How Can Tablespace Be Moved To Another Dasd Volume That Is Allocated For That Tablespace?
Answer: 
Tablespace that you are using is allocated only to STOGROUP, then you can enter the command ALTER STOGROUP for adding as well as deleting volume. REORG TABLESPACE and RECOVER TABLESPACE are statements that are helpful in creating new STOGROUP that can point towards the new volume. ALTER tablespace and REORG and RECOVER are statements used for altering and recovering the tablespace allocated in the memory.

Data manager can be considered as a component that is capable of managing the databases that are physically present and is capable of invoking other components associated with the system for performing functionalities like logging, locking and in performing other I/O operations.

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

56. How does DB2 store NULL physically?
Answer:
 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.

57.What happens to the PLAN if index used by it is dropped?
Answer:
 Plan is marked as invalid. The next time the plan is accessed, it is rebound.

58. What is lock escalation?
Answer:
 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.

59. Is DECLARE TABLE in DCLGEN necessary? Why it used?
Answer
: 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.

60.What is a predicate?
Answer:
 A predicate is an element of a search condition that expresses or implies a comparison operation.

61. What will the DB2 optimizer do?
Answer:
 The optimizer is a DB2 component that processes SQL statements and selects the access paths.

62. What is a buffer pool?
Answer: 
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.

63. What Is The Difference Between Join And Union?
Answer: 
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.

64. What is the physical storage length of each of the following DB2 data types : DATE, TIME, TIMESTAMP?
Answer:
 DATE: 4 bytes

TIME: 3 bytes

TIMESTAMP: 10 bytes

65. What is a collection?
Answer:
 A user defined name that is the anchor for packages. It has not physical existence. Main usage is to group packages.

66. When will you choose to run RUNSTATS?
Answer: 
After a load, or after mass updates, inserts, deletes, or after REORG.

67. What Will The Db2 Optimizer Do?
Answer: 
The optimizer is a DB2 component that processes SQL statements and selects the access paths.

68. Explain About Rct?
Answer: 
RCT is expanded as Resource – Control Table and is defined in the DB2/CICS region. This is the component that comprises of features that are gathered through macros of DSNCRCT. RCT matches with the transaction ID that of CICS, with the authorization ID that of DB2. This should also be matched with plan ID.

69. Can Db2 Be Accessed By Tso Users? If Yes, Which Command Is Used To Invoke Db2.
Answer:
 When a view is created, system information about the view is stored in SYSIBM.SYSVIEWS

70. In A Db2-cics Program Which Is Acts As Co-ordinator And Which Is Participant?
Answer:
 DB2 – participant CICS- coordinator.

Note: Browse latest IBM Interview Questions and DataPower training videos. Here you can check DataPower Online Training details and DataPower Training Videos for self learning. Contact +91 988 502 2027 for more information.

Leave a Comment

FLAT 30% OFF

Coupon Code - GET30
SHOP NOW
* Terms & Conditions Apply
close-link