DB2 by Mainframe Gurukul
DB2 by Mainframe Gurukul
Add to Favorites
www.mainframetutorials.com/DB2.html 1/18
4/9/23, 4:53 PM DB2 INTERVIEW QUESTIONS AND ANSWERS
YES.
Because SALARY is not declared to have NULLs and the employees for whom the
salary is not known are also counted.
9) How do you concatenate the FIRSTNAME and LASTNAME from EMP table to
give a complete name?
Both these are used to combine the results of different SELECT statements.
Suppose I have five SQL SELECT statements connected by UNION/UNION ALL, how
many times should I specify UNION to eliminate the duplicate rows? -
Once.
It has to be in a CURSOR.
www.mainframetutorials.com/DB2.html 2/18
4/9/23, 4:53 PM DB2 INTERVIEW QUESTIONS AND ANSWERS
Yes.
15) What is 'LIKE' used for in WHERE clause? What are the wildcard
characters? �
LIKE is used for partial string matches. �%� ( for a string of any character ) and
�_� (for any single character ) are the two wild card characters.
To do partial search e.g. to search employee by name, you need not specify the
complete name; using LIKE, you can search for partial string matches.
17) What is the meaning of underscore ( �_� ) in the LIKE statement? �
GROUP BY partitions the selected rows on the distinct values of the column on which
you group by.
19) Consider the employee table with column PROJECT nullable. How can you get
a list of employees who are not assigned to any project?
SELECT EMPNO
FROM EMP
SELECT SUM(SALARY)
FROM EMP
WHERE QUAL=�MSC�;
NULL
If the table structure is changed ( a field is added ), the program will have to be
modified
Program might retrieve the columns which it might not use, leading on I/O over head.
A subquery in which the inner ( nested ) query refers back to the table in the outer
query. Correlated subqueries must be evaluated for each qualified row of the outer
query that is referred to.
22) What are the issues related with correlated subqueries? �
???
Cursor is a programming device that allows the SELECT to find a set of rows but return
them one at a time.
Cursor should be used because the host language can deal with only one row at a time.
24) How would you retrieve rows from a DB2 table in embedded SQL? �
Either by using the single row SELECT statements, or by using the CURSOR.
Apart from cursor, what other ways are available to you to retrieve a row from a table in
embedded SQL? -
25) Where would you specify the DECLARE CURSOR statement? �
26) How do you specify and use a cursor in a COBOL program? �
If there is an ORDER BY clause, rows are fetched, sorted and made available for the
FETCH statement. Other wise simply the cursor is placed on the first row.
No.
29) Can you have more than one cursor open at any one time in a program ? �
www.mainframetutorials.com/DB2.html 4/18
4/9/23, 4:53 PM DB2 INTERVIEW QUESTIONS AND ANSWERS
Yes.
30) When you COMMIT, is the cursor closed? - drona db2 interview questions
Yes.
31) How do you leave the cursor open after issuing a COMMIT? ( for DB2 2.3 or
above only )
Use WITH HOLD option in DECLARE CURSOR statement. But, it has not effect in
psuedo-conversational CICS programs.
...
10 REMARKS.
33) What is the physical storage length of each of the following DB2 data types:
DATE: 4bytes
TIME: 3bytes
TIMESTAMP: 10bytes
34) What is the COBOL picture clause of the following DB2 data types:
35) What is the COBOL picture clause for a DB2 column defined as
DECIMAL(11,2)? - Ramesh
Note: In DECIMAL(11,2), 11 indicates the size of the data type and 2 indicates the
precision.
DeCLarations GENerator: used to create the host language copy books for the table
definitions. Also creates the DECLARE table.
www.mainframetutorials.com/DB2.html 5/18
4/9/23, 4:53 PM DB2 INTERVIEW QUESTIONS AND ANSWERS
1. EXEC SQL DECLARE TABLE statement which gives the layout of the table/view in
terms of DB2 datatypes.
2. A host language copy book that gives the host variable definitions for the column
names.
38) Is it mandatory to use DCLGEN? If not, why would you use it at all? -
Using DCLGEN, helps detect wrongly spelt column names etc. during the pre-compile
stage itself ( because of the DECLARE TABLE ). DCLGEN being a tool, would
generate accurate host variable definitions for the table reducing chances of error.
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.
No. Because the precompiler does not refer to the DB2 catalogue tables.
1. Use DSN utility to run a DB2 batch program from native TSO. An example is shown:
DSN SYSTEM(DSP3)
END
2. Use IKJEFT01 utility program to run the above DSN command in a JCL.
Assuming that a site�s standard is that pgm name = plan name, what is the easiest
way to find out which pgms are affected by change in a table�s structure ?
43) How can you quickly find out the # of rows updated after an update statement?
EXPLAIN is used to display the access path as determined by the optimizer for a SQL
statement. It can be used in SPUFI (for single SQL statement ) or in BIND step (for
embedded SQL ).
www.mainframetutorials.com/DB2.html 6/18
4/9/23, 4:53 PM DB2 INTERVIEW QUESTIONS AND ANSWERS
In userid.PLAN_TABLE
47) EXPLAIN has output with MATCHCOLS = 0. What does it mean? �
SELECT EMP_NAME
FROM EMP
I use CS and update a page. Will the lock be released after I am done with that page?
No.
www.mainframetutorials.com/DB2.html 7/18
4/9/23, 4:53 PM DB2 INTERVIEW QUESTIONS AND ANSWERS
www.mainframetutorials.com/DB2.html 8/18
4/9/23, 4:53 PM DB2 INTERVIEW QUESTIONS AND ANSWERS
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.
Determine the point at which DB2 acquires or releases locks against table and
tablespaces, including intent locks.
63) What else is there in the PLAN apart from the access path? �
PLAN has the executable code for the SQL statements in the host program
www.mainframetutorials.com/DB2.html 9/18
4/9/23, 4:53 PM DB2 INTERVIEW QUESTIONS AND ANSWERS
Plan is marked as invalid. The next time the plan is accessed, it is rebound.
They contain executable code for SQL statements for one DBRM.
3. Avoid the entire transaction being unavailable during bind and automatic rebind of a
plan
a user defined name that is the anchor for packages. It has not physical existence. Main
usage is to group packages.
In SPUFI suppose you want to select max. of 1000 rows , but the select returns only 200
rows.
69) How would you print the output of an SQL statement from SPUFI? �
70) How do you pull up a query which was previously saved in QMF ? �
??
71) Lot of updates have been done on a table due to which indexes have gone
haywire. What do you do? �
Looks like index page split has occurred. DO a REORG of the indexes.
73) When is the access path determined for dynamic SQL? �
74) Suppose I have a program which uses a dynamic SQL and it has been
performing well till now. Off late, I find that the performance has deteriorated.
www.mainframetutorials.com/DB2.html 10/18
4/9/23, 4:53 PM DB2 INTERVIEW QUESTIONS AND ANSWERS
Probably RUN STATS is not done and the program is using a wrong index due to
incorrect stats.
Probably RUNSTATS is done and optimizer has chosen a wrong access path based on
the latest statistics.
as an extra-byte prefix to the column value. physically, the nul prefix is Hex �00�
if the value is present and Hex �FF� if it is not.
76) How do you retrieve the data from a nullable column? �
77) What is the picture clause of the null indicator variable? �
S9(4) COMP.
78) What does it mean if the null indicator has -1, 0, -2? �
A DB2 utility used to collect statistics about the data values 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.
A state in which, an image copy on a table needs to be taken, In this status, the table is
available only for queries. You cannot update this table. To remove the COPY
PENDING status, you take an image copy or use REPAIR utility.
When a table is LOADed with ENFORCE NO option, then the table is left in CHECK
PENDING status. It means that the LOAD utility did not perform constraint checking.
A QUIESCE flushes all DB2 buffers on to the disk. This gives a correct snapshot of the
database and should be used before and after any IMAGECOPY to maintain
consistency.
Causes the data rows to be stored in the order specified in the index. A mandatory index
defined on a partitioned table space.
Only one.
91) What is the difference between primary key & unique index ?
Primary : a relational database constraint. Primary key consists of one or more columns
that uniquely identify a row in the table. For a normalized relation, there is one
designated primary key.
Unique index: a physical object that stores only unique values. There can be one or
more unique indexes on a table.
www.mainframetutorials.com/DB2.html 12/18
4/9/23, 4:53 PM DB2 INTERVIEW QUESTIONS AND ANSWERS
Authorization failure
This is generated when the consistency tokens in the DBRM and the load module are
different.
Not all of them. Some views are updateable e.g. single table view with all the fields or
mandatory fields. Examples of non-updateable views are views which are joins, views
that contain aggregate functions(such as MIN), and views that have GROUP BY clause.
96) If I have a view which is a join of two or more tables, can this view be
updateable? �
No.
Inner Join: combine information from two or more tables by comparing all values that
meet the search criteria in the designated column or columns of on e table with all the
clause in corresponding columns of the other table or tables. This kind of join which
involve a match in both columns are called inner joins.
Outer join is one in which you want both matching and non matching rows to be
returned. DB2 has no specific operator for outer joins, it can be simulated by combining
a join and a correlated sub query with a UNION.
FREEPAGE: Number of pages to be loaded with data between each free page
Simple Tablespace:
Rows from multiple tables can be interleaved on a page under the DBAs control and
maintenance
Segmented Tablespace:
Partitioned Tablespace:
Tablespace is divided into parts and each part is put in a separate VSAM dataset.
Synonym is an alternate name for a table or view used mainly to hide the leading
qualifier of a table or view.. A synonym is accessible only by the creator.
ALIAS: is retained even if table or tablespace is dropped. ALIAS can be created even if
the table does not exist. It is used mainly in distributed environment to hide the location
info from programs. Alias is a global object & is available to all.
105) What do you mean by NOT NULL WITH DEFAULT? When will you use it?
This column cannot have nulls and while insertion, if no value is supplied then it wil
have zeroes, spaces or date/time depending on whether it is numeric, character or
date/time.
Use it when you do not want to have nulls but at the same time cannot give values all
the time you insert this row.
106) What do you mean by NOT NULL? When will you use it?
When a column which contains long text, e.g. remarks, notes, may have in most cases
less than 50% of the maximum length.
1. Can lead to high space utilization if most of the values are close to maximum.
First CREATE MANAGER table with EMP# as the primary key. Then ALTER it to
define the foreign key.
When is the authorization check on DB2 objects done - at BIND time or run time?
At run time.
Recording SQL statements that access a table. Specified at table creation time or
through alter.
Interview Questions 1 | Interview Questions 2 | Interview Questions 3 | Interview
Questions 4 | Interview Questions 5 |
Interview Questions 6 | Interview Questions 7 | Interview Questions 8 | Interview
Questions 9 | Interview Questions 10 |
Interview Questions 11 | Interview Questions 12 | Interview Questions 13 | Interview
Questions 14 | Interview Questions 15 |
Interview Questions 16 | Interview Questions 17 | Interview Questions 18 | Interview
Questions 19 | Interview Questions 20 |
Interview Questions 21 | Interview Questions 22 |
Java inteview questions DB2 SQL Tutorial Mainframe inteview questions >
Mainframe inteview questions
Java inteview questions DB2 SQL Tutorial Mainframe inteview questions >
Mainframe inteview questions
DB2 query !!
DB2 Certification
db2 703 application developmetn certification
DB2
db2 query
How to know the Primary and Foriegn keys?
www.mainframetutorials.com/DB2.html 15/18
4/9/23, 4:53 PM DB2 INTERVIEW QUESTIONS AND ANSWERS
Inserting NULL
bulk insert
Call & Execute a COBOL-DB2 from a COBOL program?
Important Links Mainframes
SQL update query - need help urgently please
Reg: DCLGEN copybook compilation
Testing a field in db2.
Using Index
doubt in db2
Locking Heirarcy and Compatibility?
what s the difference between DB2 & ADB2?
Performance tuning..
Various Locking mechanism for cursors and other SQL?
IJKEFT01 or IJKEFT1A
Calling a COBOL DB2 subroutine using non-DB2 program
PERFORMANCE TUNING.
Finding PLAN(or Package)
Updating a Table?
DB2 References
SINGLE ROW
A query in DB2 with "<>".
Query on SQL
How to handle the null indiactor
Reg: CASE usage in DB2
Reg : DB2 700 certification
DB2 table -selective download to a flat file
db2 certification
latest and best DB2 certification
DB2 Questions - answers required.
DB2 catalog tables
Reg:Performance of a DB2 query
S0C6 Abend while Opening a Cursor in a DB2-PLI Proram - Sugg
S0C6 Abend while Opening a Cursor in a DB2-PLI Proram
Reg : DB2 certifications
DSNTIAUL
Deleting large numbers of rows quickly
NULL value
DB2 Certification Guidelines
date -updation
DB2 PERFORMANCE TUNING TIPS
DB2 Certification
how to reteieve the cursor randomly??
Db2 DBA training needed
current date,time
Stored procedure parm limit
chords---help
db2
db2 doubt
FOREIGN KEY
VSAM LDS used in DB2
PACKAGE VS PLAN ?
to overcome -407 error in Db2
ROWID
SQLCA
www.mainframetutorials.com/DB2.html 16/18
4/9/23, 4:53 PM DB2 INTERVIEW QUESTIONS AND ANSWERS
CURSOR
To update a Comment in Lower case in DB2
What is the diff between declaring a cursor in WSS or PD?
How to display in SYSOUT?
DB2 Cursor
new member
query on sql
how to proceed
which is the best
pls help me abt these questions..
foreign key
CAST function
thanks
DB2 checkpoint-restart doubts
db2 begginer
cursors
cursors
how to resolve abends
CONSTRAINT with ON DELETE CASCADE
DB2 Query
with Hold cursor in a stored procedure
Difference between IBMLOAD and BMCLOAD
How you add column in between a table?
Partition 1 is in Copy Pending
I am beginer in db2 , why r using bind ,plan & packge?
sql query required
DB2 SQL CODE -904 Explainations
how to see VSAM DATASET
Hi, query for table structure?
Array setup
can any one tel something about db2 loading
Get week from date
How to add two coloumns of table inm DB2
Db2 Certificaiton Info needed
DB2 certification
DB2 basic
DB2 COMMIT??
Regarding Host variables
Doubt in cursor
HOME
DB2 Interview Questions
DB2 INTERVIEW QUESTIONS
www.mainframetutorials.com/DB2.html 17/18
4/9/23, 4:53 PM DB2 INTERVIEW QUESTIONS AND ANSWERS
www.mainframetutorials.com/DB2.html 18/18