DB2 Interview Questions and Answers

DB2 Interview Questions and Answers

Last updated on 05th Oct 2020, Blog, Interview Question

About author

Wilson (Sr Technical Project Manager )

Highly Expertise in Respective Industry Domain with 10+ Years of Experience Also, He is a Technical Blog Writer for Past 4 Years to Renders A Kind Of Informative Knowledge for JOB Seeker

(5.0) | 14563 Ratings 1762

Db2 is a family of data management products, including database servers, developed by IBM. They initially supported the relational model, but were extended to support object-relational features and non-relational structures like JSON and XML. The brand name was originally styled as DB/2, then DB2 until 2017 and finally changed to its present form. DB2 is a subsystem of the MVS operating system. It is a Database Management System ( DBMS ) for that operating system.

1. What is an access path?

Ans:

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

2. What is an alias?

Ans:

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

3. Explain what a plan?

Ans:

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

4. What information is used as input to the binding process?

Ans:

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

5. What is meant by the attachment facility?

Ans:

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

6. What is meant by AUTO COMMIT?

Ans:

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

7. What is the base table?

Ans:

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

8. What is a buffer pool?

Ans:

A buffer pool is the 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.

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

Ans:

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

10. What will the COMMIT accomplish?

Ans:

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.

11. What is cursor stability?

Ans:

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 the program moves from one row to another. Other programs may read or the first row.

12. What is the function of the Data Manager?

Ans:

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

Subscribe For Free Demo

Error: Contact form not found.

13. What is a data page?

Ans:

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.

14. What is the Declaration Generator ( DCLGEN )?

Ans:

DCLGEN is a facility that is used to generate SQL statements that describe a table or view. These tables 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.

15.  What will the FREE command do to a plan?

Ans:

It will drop ( delete ) that existing plan.

16. What is a host variable?

Ans:

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.

17. What will the DB2 optimizer do?

Ans:

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

18. What is a page?

Ans:

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

19.  What is page space?

Ans:

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.

20. What is a predicate?

Ans:

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

21. What is a recovery log?

Ans:

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.

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

Ans:

The RCT is a table that is defined to a DB2/CICS region. It contains control characteristics that 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).

23. Where are plans stored?

Ans:

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

24. What is meant by repeatable read?

Ans:

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.

25. Describe what a storage group (STOGROUP) is?

Ans:

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

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

Ans:

If the tablespace used is only allocated do that STOGROUP :

  • ALTER STOGROUP- add volume (new ) delete volume (old )
  • REORG TABLESPACE or RECOVER TABLESPACE

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

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

Ans:

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

28. What is meant by a unit of recovery?

Ans:

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

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

Ans:

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

30. What is a DB2 catalog?

Ans:

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

31. What information is held in SYSIBM.SYSCOPY?

Ans:

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

32. What information is contained in an SYSCOPY entry?

Ans:

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.

33. What information can you find in SYSIBM.SYSLINKS table?

Ans:

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

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

Ans:

This information can be found in SYSIBM.SYSINDEXES.

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

Ans:

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.

Course Curriculum

Best In-Depth Practical Oriented DB2 Training By Expert Trainers

  • Instructor-led Sessions
  • Real-life Case Studies
  • Assignments
Explore Curriculum

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

Ans:

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

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

Ans:

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

38. Is DECLARE TABLE in DCLGEN necessary? Why did it use it?

Ans:

It is not necessary to have a 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.

39. How is a typical DB2 batch program executed?

Ans:

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) END

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

40. Name some of the fields from SQLCA?

Ans:

SQLCODE, SQLERRM, SQLERRD

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

Ans:

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

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

Ans:

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

  • SELECT EMP_NAME FROM EMP WHERE EMP_SALARY

43. What are the isolation levels possible?

Ans:

CS: Cursor Stability

RR: Repeatable Read

44. What is the difference between CS and RR isolation levels?

Ans:

CS: Release the lock on a page after use

RR: Retains all locks acquired till the end of the transaction

45.  When do you specify the isolation level? How?

Ans:

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

46. How does DB2 determine what lock-size to use?

Ans:

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

47. What is lock escalation?

Ans:

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 a single tablespace for escalation to occur.

48. What are the various locks available?

Ans:

SHARE, EXCLUSIVE, UPDATE

49. What is ALTER?

Ans:

SQL command used to change the definition of DB2 objects.

50. What is a DBRM, PLAN?

Ans:

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.

51. What is ACQUIRE/RELEASE in BIND?

Ans:

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

52. What lse is there In the PLN apart from the access path?

Ans:

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

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

Ans:

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

54. What are PACKAGES?

Ans:

They contain executable code for SQL statements for one DBRM.

55. What are the advantages of using a PACKAGE?

Ans:

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

Learn In-Demand Industry Experts Curated DB2 Certification Course

Weekday / Weekend BatchesSee Batch Details

56. What is a collection?

Ans:

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

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

Ans:

Print the output dataset.

58. What is dynamic SQL?

Ans:

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

59.  When is the access path determined for dynamic SQL?

Ans:

At run time, when the PREPARE statement is issued.

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

Ans:

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.

61. How does DB2 store NULL physically?

Ans:

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.

62. How do you retrieve the data from a nullable column?

Ans:

Use null indicators.

Syntax

  • INTO HOSTVAR: NULLED

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

Ans:

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

64. How do you insert a record with a nullable column?

Ans:

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

65. What is RUNSTATS?

Ans:

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.

66. When will you choose to run RUNSTATS?

Ans:

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

67. What is the reason that the MySQL statement “SELECT AVG (SALARY) FROM EMP” generates inaccurate output? 

Ans:

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.

68.  Why is SELECT not preferred in embedded SQL programs?

Ans:

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.

69. What is the picture clause of the Null Indicator variable?

Ans:

S9(4) COMP is the picture clause of a null indicator.

70. Which component checks DB2 deadlocks?

Ans:

Locking services are provided by the Locking services component which is known as Internal Resource Lock Manager (IRLM) and manages concurrency issues and deadlocks.

71. Which component is responsible for execution of SQL statements?

Ans:

Database services component is responsible for execution of SQL statements and it manages buffer pool also.

72. Which component handles DB2 startup and shutdown?

Ans:

System services component handles DB2 startup and shutdown.

73. On which level we can apply the locks?

Ans:

Locking can be applied on either of these − Page, table and table space.

74. In which step we specify the isolation level?

Ans:

In Bind step we specify the isolation level.

75. Which field in SQLCA shows the number of updated rows after the update statement?

Ans:

Check the value of SQLERRD to know how many rows got updated after an update statement.

Db2 Sample Resumes! Download & Edit, Get Noticed by Top Employers! Download

76. What is the physical storage length of TIMESTAMP data type?

Ans:

TIMESTAMP data type takes 10 bytes and default is YYYY-MM-DD:HH:MM:SS-NNNNNN

77. What is the physical storage length of DATE data type?

Ans:

DATE data types take 4 bytes and default is ‘YYYY-MM-DD’

78. Which component is used to process SQL statements and selects the access paths?

Ans:

DB2 optimizer is used to select the access paths & to process the SQL queries.

79. In a COBOL-DB2 program all SQL statements must be coded in Area A. State whether true or false?

Ans:

This statement is incorrect as SQL statements must be coded in Area B.

80. Suppose a Plan contains 4 Packages & we modified one of the DBRM which is present in one of the Packages. Then for normal application functionality what should we do?

Ans:

We will bind only that package which contains the modified DBRM. No need to bind all the packages.

81. Cursors are used to handle single row selections at a time. They are data structures which hold all the results of a query. State whether true or false?

Ans:

This statement is incorrect as cursors are used to handle multiple row selections at a time.

82. Host variables cannot be group items but they may be grouped together in host structure. They can be Renamed or Redefined. State whether true or false?

Ans:

This statement is incorrect as host variables cannot be renamed & redefined.

83. When a table is dropped all the aliases get dropped automatically. State whether true or false?

Ans:

This statement is incorrect. Synonyms get dropped automatically when we drop the table but the alias of the table remains there. We need to manually drop the alias.

84. What action DB2 takes when a program abends?

Ans:

When a program aborts in the middle of some transaction then DB2 performs an auto rollback.

85. If a transaction takes a Update lock on some data, then other transactions can get what type of lock?

Ans:

If a transaction takes an Update lock on some data, then other transactions can only get only Shared lock on it.

86. If a transaction takes a Shared lock on some data, then other transactions can get what type of lock?

Ans:

If a transaction takes a Shared lock on some data, then other transactions can get either a Shared or Update lock on it.

87. How can the locks be classified?

Ans:

Locks can be classified based on size, duration and mode.

88. Which utility is used to load data into a table from a sequential file?

Ans:

Load utility is used to load data into tables.

89. Which utility reclaims space from pages when some rows were deleted?

Ans:

Reorg utility is used for reorganization of data on physical storage.

90. Which utility provides statistical information such as the number of pages and rows and stores them in Catalog tables?

Ans:

Runstats utility updated the catalog tables with the statistical information.

91. Which command is used to commit a transaction in the CICS program?

Ans:

SYNCPOINT command is used to commit a transaction in a CICS program.

92. Which isolation level provides maximum concurrency?

Ans:

Uncommitted read provides maximum concurrency.

93. Which isolation level ensures highest data integrity?

Ans:

Repeatable Read ensures highest data integrity as it holds page and lock the rows until a COMMIT point.

94. If a transaction has an exclusive lock on some data, then what are the other types of lock which can be applied on it?

Ans:

A transaction gets an Exclusive lock when it is about to write at that time no other lock can be applied on it.

95. What is the input to the bind process?

Ans:

DBRM is the input to the bind process which is produced in the pre-compile step.

96. How will you count the number of rows from a table TAB?

Ans:

  • SELECT COUNT(*) FROM TAB query is used to count the number of rows in a table.

97. Suppose we added a new column by using the ALTER statement, where the column will be added?

Ans:

When we use the ALTER statement for adding a new column then it will be added at the end of the table.

98. In a COBOL-DB2 program where can we declare a cursor?

Ans:

We can declare a cursor either in the Working Storage Section or in the Procedure Division also.

99. What does the application plan contain?

Ans:

Application plan consists of one or more DBRM & application packages which are kept in a buffer pool during program execution.

Are you looking training with Right Jobs?

Contact Us

Popular Courses