IBM DB2 Interview Questions

Ratings:
(4.5)
Views:5486
Banner-Img
  • Share this blog:

 

IBM DB2 Interview Questions

1Q) What is DB2 ( IBM Database 2 )?

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

2Q) What is an access path?

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

3Q) 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

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

Inclined to build a profession as IBM DB2? Then here is the blog post on, explore "IBM DB2 Training"

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

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

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

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

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

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

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

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

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

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

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

16Q) What will the FREE command do to a plan?

Ans: It will drop ( delete ) that existing plan.

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

18Q) What will the DB2 optimizer do?

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

19Q) What is a page?

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

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

IBM DB2 Certification Questions

21Q) What is a predicate?

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

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

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

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

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

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

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

28Q) 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)

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

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

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

32Q) What information is held in SYSIBM.SYSCOPY?

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

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

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

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

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

37Q) What is DCLGEN?

Ans: DCLGEN stands for declarations generator, it is a facility to generate DB2 SQL data structure in COBOL or PL/I programs.

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

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

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

39Q) What is DCLGEN?

Ans: DeClarations GENerator: used to create the host language copy books for the table definitions. Also creates the DECLARE table.

40Q) Is DECLARE TABLE in DCLGEN necessary? Why did it use?

Ans: It 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.

IBM DB2 Interview Questions for Experienced

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

42Q) Name some of the fields from SQLCA?

Ans: SQLCODE, SQLERRM, SQLERRD

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

44Q) 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 > ?

45Q) What are the isolation levels possible?

Ans: CS: Cursor Stability

RR: Repeatable Read

46Q) 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

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

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

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

51Q) What are the various locks available?

Ans: SHARE, EXCLUSIVE, UPDATE

52Q) What is ALTER?

Ans: SQL command used to change the definition of DB2 objects.

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

54Q) What is ACQUIRE/RELEASE in BIND?

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

55Q) What else is there Ain the PLN apart from the access path?

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

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

57Q) What are PACKAGES?

Ans: They contain executable code for SQL statements for one DBRM.

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

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

60Q) How would you print the output of an SQL statement from SPUFI?

Ans: Print the output dataset.

61Q) What is dynamic SQL?

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

62Q) When is the access path determined for dynamic SQL?

Ans: At run time, when the PREPARE statement is issued.

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

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

65Q) How do you retrieve the data from a nullable column?

Ans: Use null indicators. Syntax .. INTO HOSTVAR: NULLED

66Q) What is the picture clause of the null indicator variable?

Ans: S9(4) COMP.

67Q) 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

68Q) 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

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

70Q) When will you choose to run RUNSTATS?

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

71Q) Why SELECT is 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.

About Author
Authorlogo
Name
TekSlate
Author Bio

TekSlate is the best online training provider in delivering world-class IT skills to individuals and corporates from all parts of the globe. We are proven experts in accumulating every need of an IT skills upgrade aspirant and have delivered excellent services. We aim to bring you all the essentials to learn and master new technologies in the market with our articles, blogs, and videos. Build your career success with us, enhancing most in-demand skills in the market.


Stay Updated


Get stories of change makers and innovators from the startup ecosystem in your inbox