FREE Web Template Download
HTML CSS JAVASCRIPT SQL PHP BOOTSTRAP JQUERY ANGULARJS TUTORIALS REFERENCES EXAMPLES Blog
 

Top DB2 Interview Questions and Answers



Top 50 DB2 Interview Questions

1.) Define DB2.

DB2 is a Database Management System for the MVS Operating System where, DB2 is a subsystem of MVS Operating System.

2.) What is the purpose of using COMMIT?

The data changes can be made permanent by using COMMIT. It also permits data to be accessed by other applications who can reference the committed data

3.) List out the Data types available.

The Data types available here are:

1. SMALLINT

2. INTEGER

3. FLOAT

4. DECIMAL

5. CHAR

6. VARCHAR

7. DATE

8. TIME 

4.) What are the uses of DB2 Optimizer?

1.           It processes SQL statements.

2.           It helps to select the access path

5.) Define SQLCA.

SQL Communication Area is a structure of variables, which are updated after every execution of SQL statements. For an application that contains executable SQL statements, only one SQLCA is needed. FORTRAN need more than one SQLCA to be provided .For Java, SQLCA is not applicable.

DB2 Interview Questions and Answers «

6.) Define CHECK constraint.

It is specified as a condition or criteria to ensure data integrity. A value to be inserted or updated to a table is tested by CHECK constraint. The CHECK constraints are created during the creation of the table.

7.) What is SQLCA’s maximum length?

136 is the maximum length of the SQLCA.

8.) Discuss about DB2 bind?

The process that builds access paths to the DB2 table is known as bind. The bind uses Database Request Modules  from the DB2 pre-compile step as input and produces an application plan. It checks for user authentication and validates SQL statements in the DBRM(s).

9.) List out the three types of page locks that can be held.

1.           Exclusive

2.           Update

3.           Share.

10.) Define buffer pool.

 The buffer pool is a reserved main storage, which is to satisfy the buffering requirements for one or more table spaces or indexes. It can be made up of either 4K or 32K pages.

 11.) Explain the function of Data Manager.

The physical database is managed by the DB2 component called Data manager. It invokes other system components to perform logging, locking etc.

12.) What is a storage group (STOGROUP)?

STOGROUP is a named collection of DASD volumes, which is to be used by index spaces and table spaces of the database.

13.) Define predicate?

Predicate is an element of a search condition. It expresses or implies a search condition.

14.) Define Declaration Generator (DCLGEN).

Declaration Generator is a facility that is used to form SQL statements that describes a table or view. At pre-compile time, the table or view descriptions are then used to check the validity of SQL statements.

15.) List out the buffer pools in DB2

There are four buffer pools in DB2 and they are:

1.           BP0

2.           BP1

3.           BP2

4.           BP32

16.) Define clustering index.

Clustering index is a type of index, which locates the table rows and determines how to group the rows together in the tablespace.

17.) What is concurrency?

More than one DB2 application process can access the same data at the same time, is known as concurrency. However, problems can happen such as, lost updates access to unrepeatable reads and uncommitted data.

18.) Explain the Function done by data manager?

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.

19.) Explain about DBRM.

DBRM stands for Database Request Module and is a component inside DB2, which is created by the pre compiler of DB2. This is a module that consists of SQL source statements that get extracted out of the application program. DBRMs form inputs that are helpful in the binding process.

20.) Define Data page.

Data page can be considered as a unit that is capable of retrieving data from the database. The database from which the data can be retrieved is in the form of 4 kilobytes or 32 kilobytes. The form in which data is retrieved depends on the way the table is defined inside the database. Data page also contains information regarding the catalog or user that are part of the database.

21.) Explain about RCT.

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.

22.) How can tablespace be moved to another DASD volume that is allocated for that tablespace?

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.

23.) What is the information associated with SYSIBM.SYSLINKS table?

This is the table that contains information on the links that exists between the tables created through referential constraints.

24.) Explain in detail about buffer manager and its functionalities?

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.

25.) Explain about cursor stability?

Cursor stability is the property that tells the DB2 that the values of database that are read by making use of this application gets protected while the data is used.

26.) Mention a credible reason why SELECT* is never given preference in an SQL program that has been embedded.

There are primarily three reasons why SELECT* is never given preference in an embedded SQL program. These are: –

·          In case if there is an alteration in the structure of the table, then the program has to undergo a modification process.

·          All columns will be retrieved by the program including those columns , which might not be used.

·          In case if the user wishes to scan the index, then that will not be possible.

 

27.) Explain correlated sub-queries.

Correlated sub-queries are those queries wherein the nester query on the inner side refers directly back to outer query’s table. For each and every row that is qualified, the evaluation of correlated sub-query is a must.

28.) Comment whether the cursor is closed during COMMIT or not.

Yes. The cursor is closed during COMMIT.

29.) In an SQL table that is embedded, what is the procedure to retrieve rows that are part of a DB2 table?

Either you can use SELECT statements of single rows or an alternative way is to use CURSOR.

30.) Mention the way of highlighting as well as putting a CURSOR to use in a COBOL program.

The best way of putting a CURSOR to use in a COBOL program is to make use of DECLARE CURSOR, which can be used either in procedure division operation or in working storage. This is being done basically to highlight the SELECT statement. Once DECLARE CURSOR is used, this is followed by OPEN, FETCH and finally CLOSE.

31.) If the CURSOR is kept open followed the issuing of COMMIT, what is the procedure to leave the CURSOR that way?

Inside DECLARE CURSOR, there is a WITH HOLD option, which will come useful in this case. Although, one should note the point that WITH HOLD function has absolutely no effect if considered for CICS pseudo-conventional programs.

32.) Explain PACKAGES.

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

33.) Highlight all the advantages that are attached to a PACKAGE.

Following are the advantages attached to a PACKAGE.

·          Avoid the cost of a large collection of bind. It is much more advisable to go for a small collection instead of a large one.

·          Ensure that you do not have to bring a large collection of members of DBRM together for a particular plan.

·          In case if you wish to make changes in the program and these changes eventually lead to errors, then you can decrease the fallback complexities with the help of PACKAGE.

·          During the process of automatic binding and rebinding of a particular plan, make sure that the total transaction attached to the process is unavailable during the course.

 34.) Mention the definition of COBOL in VARCHAR field.

The REMARKS of VARCHAR column are as follows: –

10 REMARKS

49 REMARKS – LEN PIC S9 (4) USAGE COMP.

49 REMARKS – TEXT PIC X (1920). 

35.) Mention the length of physical storage of the given data types of DB2 – DATE, TIMESTAMP, TIME

 

1) DATE: PIC X (10)

2) TIMESTAMP: PIC X (26)

3) TIME: PIC X (08)

 

36.) For a DB2 column that is being defined as DECIMAL (11, 2), discuss the COBOL picture clause.

PIC S9 (9) V99 COMP – 3

In the expression DECIMAL (11, 2)  2 happens to be the precision whereas 11 is the data type size.

37.) Explain DCLGEN.

DCLGEN basically refers to DeCLarations GENerator whose primary purpose is to generate copy books of the host language for the tables. It is also used to create the DECLARE table.

38.) Mention some fields that are a part of SQLCA.

SQLERRM, SQLCODE, SQLERRD.

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

40.) Comment whether DCLGEN is mandatorily used. If not, then what is the point of using it?

It is not exactly mandatory to bring DCLGEN into use. The primary use of DCLGEN comes during the pre-compilation phase where it helps in detecting the misspelt column names. Since DCLGEN is just a tool, it will only generate variable definitions for the host and reduces the chances of errors.

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

42.) Following a DB2 update statement, what is the quickest way to compute the total number of updated rows?

All you have to do is check the value that has been stored in SQLERRD (3).

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

44.) Before you give the EXPLAIN statement, what are the prerogatives?

Before giving the EXPLAIN statement, we need to make sure that PLAN_TABLE has already been created under AUTHID.

45.) Mention the location where the output received from EXPLAIN statement is stored.

The output from EXPLAIN is stored in userid.PLAN_TABLE

46.) Outputs of EXPLAIN are with MATCHCOLS = 0. What does this signify?

This signifies a non-matching scan of index provided that ACCESSTYPE = I

47.) Mention the various locks that are available in DB2.

EXCLUSIVE, SHARE and UPDATE

48.) What is RELEASE/ACQUIRE in BIND?

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.

49.) Mention the different locking levels that are available in DB2.

TABLE, PAGE and TABLESPACE

 50.) Mention the downsides of PAGE level lock.

In case if there are large updates to be done, then the resource utilization is high accordingly.

 

DB2 Interview Questions

A list of top frequently asked DB2 interview questions and answers are given below.


1) What is DB2? Explain.

DB2 is a relational database management system (RDBMS) product form IBM. It is a subsystem for MVS Operating System. It is designed to store, analyze and retrieve data efficiently.


2) Which components manage deadlocks in DB2?

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


3) How can you classify the locks in DB2?

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


4) On which levels locks can be applied?

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


5) How many types of page locks can be held in DB2?

Three types of page locks can be held in DB2:

  • Exclusive
  • Update
  • Share

6) What is the purpose of using COMMIT in DB2?

COMMIT is used to change the data permanently. It also allows to access data by other applications that can reference the committed data.

7) What are the data types available in DB2?

The data types available in DB2 are:

  1. SMALLINT
  2. INTEGER
  3. FLOAT
  4. DECIMAL
  5. CHAR
  6. VARCHAR
  7. DATE
  8. TIME

8) What is the picture clause of Null indicator variable?

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


9) What is the use of DB2 Optimizer?

  • DB2 Optimizer is used to process the SQL statement.
  • DB2 Optimizer also helps to select the access path.

10) Which component is used to execute the SQL statements?

Database Services component is used to execute the SQL statement. It also manages buffer pool.


11) Which component is responsible for DB2 startup and shutdown?

System Services component is responsible for handling DB2 startup and shutdown.


12) What is SQLCA?

SQLCA stands for SQL Communication Area. It is a structure of variables, which are updated after every execution of SQL statements.

If an application contains executable SQL statements then only one SQLCA is needed. FORTRAN needs more than one SQLCA to be provided. For Java, SQLCA is not applicable.


13) What is the maximum length of SQLCA?

136 is the maximum length of the SQLCA.


14) Give the name of some fields form SQLCA.

The following three are the fields from SQLCA:

  • SQLCODE
  • SQLERRM
  • SQLERRD

15) What is CHECK constraint in DB2?

CHECK constraint is defined as a condition or criteria to ensure data integrity. The CHECK constraints are created during the creation of the table and each value inserted or updated to the table is tested by CHECK constraint.


16) What is DB2 Bind?

DB2 bind is a process that builds access paths to the DB2 table. It uses Database Request Modules from the DB2 pre-compile step as input and produces an application plan. It checks for user authentication and validates SQL statements in the DBRM(s).


17) What is DBRM?

DBRM stands for Database Request Module. It is a component inside DB2, which is created by the pre compiler of DB2. It contains SQL source statements that get extracted out of the application program. DBRMs form inputs that are helpful in the binding process.


18) What is buffer Pool?

Buffer pool is a reserved main storage which is used as buffering requirements for one or more table spaces or indexes. It is made up of either 4K or 32K pages.


19) What is the use of data manager?

Data manager is a DB2 component that is responsible to manage physical database. It invokes other system components to perform logging, locking etc.


20) What is a storage group (STOGROUP)?

STOGROUP is a named collection of DASD volumes. It is used by index spaces and table spaces of the database.


21) What is predicate?

Predicate is an element of a search condition. It expresses or implies a search condition.


22) What is the physical storage length of TIME data type?

The physical storage length of TIME data type is 3 bytes.


23) What is the physical storage length of DATE data type?

The physical storage length of TIME data type is 4 bytes.


24) What is the physical storage length of TIMESTAMP data type?

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


25) What is Declaration Generator (DCLGEN)?

Declaration Generator (DCLGEN) is a facility used to form SQL statements that describes a table or view. At pre-compile time, the table or view descriptions are then used to check the validity of SQL statements.


26) What are the several buffer pools in DB2?

Following are the for buffer pool in DB2:

  1. BP0
  2. BP1
  3. BP2
  4. BP32

27) Which component is responsible for processing SQL statements and selecting access paths?

DB2 optimizer is used to select the access paths and for processing SQL statements.


28) What is concurrency?

Concurrency specifies that more than one DB2 application processes can access the same data at the same time. However, problems can happen such as, lost updates access to unrepeatable reads and uncommitted data.


29) Which isolation level provides maximum concurrency?

Uncommitted read provides maximum concurrency.


30) Which isolation level provides highest data integrity?

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


31) What is RCT?

RCT stands for Resource Control Table defined in 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.


32) What action DB2 takes when a program aborts in the middle of a transaction?

DB2 performs auto rollback when a program is aborted in the middle of some transaction.


33) Where can you declare a cursor in a COBOL-DB2 program?

A cursor can be declared either in Working Storage Section or in Procedure Division also.


34) How can you count the number of rows from a table TAB?

By applying the following query:

1.    SELECT COUNT(*) FROM TAB   


35) What is the maximum size of a CHAR data type in DB2?

The maximum size of a CHAR data type in DB2 is 254 bytes.


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

The maximum size of a VARCHAR data type in DB2 is 4046 bytes.


37) What is SPUFI?

SPUFI stands for SQL Processor Using File Input.


38) What is the information associated with SYSIBM.SYSLINKS table?

This table contains information on the links that exists between the tables created through referential constraints.


39) What is cursor stability?

Cursor stability is the property that tells the DB2 that the values of database that are read by making use of this application gets protected while the data is used.


40) What is the reason behind not using SELECT * in Embedded SQL programs?

There are three reasons for not using SELECT * in embedded SQL programs:

  • If you change the structure of the table i.e. adding a field, the program will have to be modified.
  • Program can retrieve the columns which it might not use, leading an I/O overhead.
  • The chance of an index only scan is lost.

41) What is the usage of OPEN CURSOR command?

If you use the OPEN CURSOR command with ORDER BY clause, the rows are fetched, sorted and made available for the FETCH statement. Otherwise simply the cursor is placed on the first row.


42) What is the COBOL picture clause of the DB2 data types DATE, TIME, TIMESTAMP?

DATE: PIC X(10)

TIME PIC X(08)

TIMESTAMP PIC X(26)


43) What is DCLGEN?

DCLGEN is stands for DeCLarations GENErator. It is used to create the host language copy books for the table definitions. It also creates the DECLARE table.


44) What are the contents of a DCLMGEN?

  • EXEC SQL DECLARE TABLE statement which gives the layout of the table in terms of DB2 data type.
  • A host language copy book that gives the host variable definitions for the column name.

45) What are the advantages of using a package?

The package provides following advantages:

  • Modularity
  • Easy to design the applications
  • Better performance
  • Hiding information
  • Added functionality
  • Overloading