The questions and answers that follow are intended for those with a working knowledge of DB2 as a “self-test”.
Q1)What is DB2 (IBM Database 2)?
A1)DB2 is a subsystem of the MVS operating system. It is a Database Management System (DBMS) for that operating system.
Q2)What is an access path?
A2)The path that is used to get to data specified in SQL statements.
Q3)What is an alias?
A3)It is an alternate name that can be used in SQL statements to refer to a table or view in the same or remote DB2 subsystem.
Q4)Explain what a plan is?
A4)Plan is a DB2 object (produced during the bind process) that associates one or more database request modules with a plan name.
Q5)What is a DB2 bind?
A5)Bind is a processthat 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).
Q6)What information is used as input to the bind process?
A6)The database request module produced during the pre-compile. The SYSIBM.SYSSTMT table of the DB2 catalog.
Q7)What is meant by the attachment facility?
A7)The attachment facility is an interface between DB2 and TSO, IMS/VS, CICS, or batch address spaces. It allows application programs to access DB2.
Q8)What is meant by AUTO COMMIT?
A8)AUTO COMMIT is a SPUFI option that commits the effects of SQL statements automatically if they are successfully executed.
Q9)What is a base table?
A9)A base table is a real table -a table that physically exists in that there are physical stored records.
Q10)What is the function of buffer manager?
A10)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).
Q11)What is a buffer pool?
A11)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.
Q12)How many buffer pools are there in DB2?
A12)There are four buffer pools: BP0, BP1, BP2, and BP32.
Q13)On the create tablespace, what does the CLOSE parameter do?
A13)CLOSE physically closes the tablespace when no one is working on the object. DB2 (release 2.3) will logically close tablespaces.
Q14)What is a clustering index?
A14)It is a type of index that (1) locates table rows and (2) determines how rows are grouped together in the tablespace.
Q15)What will the COMMIT accomplish?
A15)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.
Q16)What is meant by concurrency?
A16)Concurrency is what allows more than one DB2 application process to access the same data at essentially the same time. Problems may occur, such as lost updates, access to uncommitted data, and un-repeatable reads.
Q17)What is cursor stability?
A17)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.
Q18)What is the function of the Data Manager?
A18)The Data Manager is a DB2 component that manager 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).
Q19)What is a Database Request Module(DBRM)?
A19)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.
Q20)What is a data page?
A20)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.
Q21)What are data types?
A21)They are attributes of columns, literals, and host variables. The data types are SMALLINT, INTEGER, FLOAT, DECIMAL, CHAR, VARCHAR, DATE and TIME.
Q22)What is Declaration Generator(DCLGEN)?
A22)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.
Q23)What does DSNDB07 database do?
A23)DSNDB07 is where DB2 does its sorting. It includes DB2’s sort work area and external storage.
Q24)What will the FREE command do toaplan?
A24)It will drop(delete) that existing plan.
Q25)What is a host variable?
A25)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.
Q26)What will the DB2 optimizer do?
A26)The optimizer is a DB2 component that processes SQL statements and selects the access paths.
Q27)What is a page?
A27)This is the unit of storage within a table space or indexspace that is accessed by DB2.
Q28)What is pagespace?
A28)Pagespace refers to either to an unpartitioned table, to an index space, or to a single partition of a partitioned table of index space.
Q29)What is a predicate?
A29)A predicate is an element of a search condition that expresses or implies a comparison operation.
Q30)What is a recovery log?
A30)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.
Q31)What is a Resource Control Table(RCT)? Describe its characteristics.
A31)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 IDand plan ID(CICS attachment facility).
Q32)Where are plans stored?
A32)Each plan is defined uniquely in the SYSIBM.SYSPLANS table to correspond to the transaction (s) that are to execute that plan.
Q33)What is meant by repeatable read?
A33)When an application program executes with repeatable read protection, rows referenced by the program can’t be changed byother programs until the program reaches a commit point.
Q34)Describe what a storage group(STOGROUP) is?
A34)A STOGROUP is a named collection of DASD volumes to be used by tablespaces and index spaces of databases. The volumes of STOGROUP must be of the same device type.
Q35)How would you move a tablespace (using STOGROUP) to a different DASD volume allocated to that tablespace?
A35)If the tablespace used is only allocated to 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
Q36)What is the format (internal layout) of “TIMESTAMP”?
A36)This is a seven part value that consists of a date (yymmdd) and time(hhmmss and microseconds).
Q37)What is meant by a unit of recovery?
A37)This is a sequence of operations within a unit of work(i.e., work done between commit points).
Q38)Can DASD types assigned to storage groups be intermixed(i.e., 3350s and 3380s)?
Q39)What are the three types of page locks that can be held?
A39)Exclusive, update, and share.
Q40)Can DB2 be accessed by TSO users? If yes, which command is used to invoke DB2?
A40)DB2 can be invoked by TSO users by using the DSN RUN command.
Q41)How are write I/Os from the buffer pool executed?
Q42)What is a DB2 catalog?
A42)The DB2 catalog is a set of tables that contain information about all of the DB2 objects(tables, views, plans etc.).
Q43)In which column of which DB2 catalog would you find the length of the rows for all tables?
A43)In the RECLENGTH column of SYSIBM.SYSTABLES
Q44)What information is held in SYSIBM.SYSCOPY?
A44)The SYSIBM.SYSCOPY table contains information about image copies made of the tablespaces.
Q45)What information is contained in a SYSCOPY entry?
A45)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.
Q46)What information can you find in SYSIBM.SYSLINKS table?
A46)The SYSIBM.SYSLINKS table contains information about the links between tables created by referential constraints.
Q47)Where would you find information about the type of database authority held by the user?
Q48)Where could you look if you had a question about whether a column has been defined as an index?
A48)This information can be found in SYSIBM.SYSINDEXES.
Q49)Once you create a view, where would information about the view be stored?
A49)When a view is created, system information about the view is stored in SYSIBM.SYSVIEWS.
Q50)What is the SQL Communications Area and what are some of its key fields?
A50)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.
Q51)What is DCLGEN?
A51)DCLGEN stands for declarations generator;it is a facility to generate DB2 sql data structures in COBOL or PL/I programs.
Q52)How do you leave the cursor open after issuing a COMMIT?(for DB2 2.3 or above only)
A52)Use WITH HOLD option in DECLARE CURSOR statement.But, it has not effect in psuedo-conversational CICS programs.
Q53)Give the COBOL definition of a VARCHAR field.
A53)A VARCHAR column REMARKS would be defined as follows:
49 REMARKS-LENPIC S9(4) USAGE COMP.
49 REMARKS-TEXTPIC X(1920).
Q54)What is the physical storage length of each of the following DB2 data types: DATE, TIME, TIMESTAMP?
Q55)What is the COBOL picture clause of the following DB2 data types:DATE, TIME, TIMESTAMP?
A55)DATE: PIC X(10)
TIME : PIC X(08)
TIMESTAMP: PIC X(26)
Q56)What is the COBOL picture clause for a DB2 column defined as DECIMAL(11,2)? - GS
A56)PIC S9(9)V99 COMP-3.
Note: In DECIMAL(11,2), 11 indicates the size of the data type and 2 indicates the precision.
Q57)What is DCLGEN ? - GS
A57)DeCLarations GENerator: used to create the host language copy books for the table definitions. Also creates the DECLARE table.
Q58)What are the contents of a DCLGEN? - GS
A58)EXEC SQL DECLARE TABLE statement which gives the layout of the table/view in terms of DB2 datatypes.
A host language copy book that gives the host variable definitions for the column names.
Q59)Is it mandatory to use DCLGEN? If not, why would you use it at all? - GS
A59)It is not mandatory to use DCLGEN. 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.
Q60)Is DECLARE TABLE in DCLGEN necessary? Why it used?
A60)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.
Q61)Will precompile of an DB2-COBOL program bomb, if DB2 is down?
A61)No.Because the precompiler does not refer to the DB2 catalogue tables.
Q62)How is a typical DB2 batch program executed ?
A62)There are two methods of executing a DB2-batch program
1. Use DSN utility to run a DB2 batch program from native TSO.An example is shown:
RUN PROGRAM(EDD470BD) PLAN(EDD470BD) LIB('EDGS01T.OBJ.LOADLIB')
2. Use IKJEFT01 utility program to run the above DSN command in a JCL.
Q63)Assuming that a site's standard is that pgm name = plan name, what is the easiest way to find out which
programs are affected by change in a table's structure?
A63)Query the catalogue tables SYSPLANDEP and SYSPACKDEP.
Q64)Name some fields from SQLCA.
A64)SQLCODE, SQLERRM, SQLERRD
Q65)How can you quickly find out the number of rows updated after an update statement?
A65)Check the value stored in SQLERRD(3).
Q66)What is EXPLAIN? - GS
A66)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).The results of EXPLAIN is stored in U.PLAN_TABLE where U is the authorization id of the user
Q67)What do you need to do before you do EXPLAIN?
A67)Make sure that the PLAN_TABLE is created under the AUTHID.
Q68)Where is the output of EXPLAIN stored? - GS
Q69)EXPLAIN has output with MATCHCOLS = 0.What does it mean? - GS
A69)A nonmatching index scan if ACCESSTYPE = I.
Q70)How do you do the EXPLAIN of a dynamic SQL statement?
A70)There are two methods to achieve this:
1. Use SPUFI or QMF to EXPLAIN the dynamic SQL statement
2. Include EXPLAIN command in the embedded dynamic SQL statements
Q71)How do you simulate the EXPLAIN of an embedded SQL statement in SPUFI/QMF? Give an example with a host variable in WHERE clause)
A71)Use a question mark in place of a host variable (or an unknown value). For instance,
SELECT EMP_NAME FROM EMP WHERE EMP_SALARY > ?
Q72)What are the isolation levels possible ? - GS
Q73)What is the difference between CS and RR isolation levels?
A73)CS:Releases the lock on a page after use
RR:Retains all locks acquired till end of transaction
Q74)When do you specify the isolation level? How?
A74)During the BIND process(ISOLATION LEVEL is a parameter for the bind process).ISOLATION ( CS/RR )...
Q75)I use CS and update a page.Will the lock be released after I am done with that page?
Q76)What are the various locking levels available?
A76)PAGE, TABLE, TABLESPACE
Q77)How does DB2 determine what lock-size to use?
A77)There are three methods to determine the lock-size.They are:
1. Based on the lock-size given while creating the tablespace
2. Programmer can direct the DB2 what lock-size to use
3. If lock-size ANY is specified, DB2 usually choses a lock-size of PAGE
Q78)What are the disadvantages of PAGE level lock?
A78)High resource utilization if large updates are to be done
Q79)What is lock escalation?
A79)Promoting a PAGE lock-size to table or tablespace lock-size when a transaction has aquired more locks than specified in NUMLKTS.Locks should be taken on objects in single tablespace for escalation to occur.
Q80)What are the various locks available?
A80)SHARE, EXCLUSIVE, UPDATE
Q81)Can I use LOCK TABLE on a view?
A81)No.To lock a view, take lock on the underlying tables.
Q82)What is ALTER ? - GS
A82)SQL command used to change the definition of DB2 objects.
Q83)What is a DBRM, PLAN ?
A83)DBRM: Data Base Request Module, has the SQL statements extracted from the host language program bythe pre-compiler. PLAN: A result of the BIND process.It has the executable code for the SQL statements in the DBRM.
Q84)What is ACQUIRE/RELEASE in BIND?
A84)Determine the point at which DB2 acquires or releases locks against table and tablespaces, including intent locks.
Q85)What else is there in the PLAN apart from the access path? - GS
A85)PLAN has the executable code for the SQL statements in the host program
Q86)What happens to the PLAN if index used by it is dropped?
A86)Plan is marked as invalid. The next time the plan is accessed, it is rebound.
Q87)What are PACKAGES ? - GS
A87)They contain executable code for SQL statements for one DBRM.
Q88)What are the advantages of using a PACKAGE?
A88)The advantages of using PACKAGE are:
1. Avoid having to bind a large number of DBRM members into a plan
2. Avoid cost of a large bind
3. Avoid the entire transaction being unavailable during bind and automatic rebind of a plan
4. Minimize fallback complexities if changes result in an error.
Q89)What is a collection?
A89)A user defined name that is the anchor for packages.It has not physical existence.Main usage is to group packages.
Q90)In SPUFI suppose you want to select maximum of 1000 rows, but the select returns only 200 rows. What are the 2 SQLCODEs that are returned? - GS
A90)+100 (for successful completion of the query), 0 (for successful COMMITif AUTOCOMMIT is set to Yes).
Q91)How would you print the output of an SQL statement from SPUFI? - GS
A91)Print the output dataset.
Q92)Lot of updates have been done on a table due to which indexes have gone haywire.What do you do?
A92)Looks like index page split has occurred.DO a REORG of the indexes.
Q93)What is dynamic SQL? - GS
A93)Dynamic SQL is a SQL statement created at program execution time.
Q94)When is the access path determined for dynamic SQL? - GS
A94)At run time, when the PREPARE statement is issued.
Q95)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.What happened? - GS
A95)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 RUNSTATS is done and optimizer has chosen a wrong access path based on the latest statistics.
Q96)How does DB2 store NULL physically?
A96)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.
Q97)How do you retrieve the data from a nullable column? - GS
A97)Use null indicators. Syntax ... INTO :HOSTVAR:NULLIND
Q98)What is the picture clause of the null indicator variable? - GS
Q99)What does it mean if the null indicator has -1, 0, -2? - GS
A99)-1: the field is null;0 : the field is not null; -2: the field value is truncated
Q100)How do you insert a record with a nullable column?
A100)To insert a NULL, move -1 to the null indicator, To insert a valid value, move 0 to the null indicator
Q101)What is RUNSTATS? - GS
A101)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.
Q102)When will you chose to run RUNSTATS?
A102)After a load, or after mass updates, inserts, deletes, or after REORG.
Q103)Give some example of statistics collected during RUNSTATS?
A103)Number of rows in the table, Percent of rows in clustering sequence, Number of distinct values of indexed column, Numberof rows moved to a nearby/fairway page due to row length increase
Q104)What is REORG?When is it used?
A104)REORG reorganizes data on physical storage to reclutser rows, positioning overflowed rows in their proper sequence, to reclaim space, to restore free space.It is used after heavy updates, inserts and delete activity and after segments of a segmented tablespace have become fragmented.
Q105)What is IMAGECOPY ? - GS
A105)It is full backup of a DB2 table which can be used in recovery.
Q106)When do you use the IMAGECOPY? - GS
A106)To take routine backup of tables, After a LOAD with LOG NO and After REORG with LOG NO
Q107)What is COPY PENDING status?
A107)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.
Q108)What is CHECK PENDING ?
A108)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.
Q109)What is QUIESCE?
A109)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.
Q110)What is a clustering index ? - GS
A110)Causes the data rows to be stored in the order specified in the index. A mandatory index defined on a partitioned table space.
Q111)How many clustering indexes can be defined for a table?
Q112)What is the difference between primary key & unique index ?
A112)Primary Key: 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.
Q113)What is sqlcode -922 ?
Q114)What is sqlcode -811?
A114)SELECT statement has resulted in retrieval of more than one row.
Q115)What does the sqlcode of -818 pertain to? - GS
A115)This is generated when the consistency tokens in the DBRM and the load module are different.
Q116)Are views updatable ?
A116)Not all of them.Some views are updatable e.g. single table view with all the fields or mandatory fields. Examples of non-updatable views are views which are joins, views that contain aggregate functions (such as MIN), and views that have GROUP BY clause.
Q117)If I have a view which is a join of two or more tables, can this view be updatable? - GS
Q118)What are the 4 environments which can access DB2 ?
A118)TSO, CICS, IMS and BATCH
Q119)What is an inner join, and an outer join ?
A119)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 one table with all the values 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.
Q120)What is FREEPAGE and PCTFREE in TABLESPACE creation?
A120)PCTFREE: percentage of each page to be left free
FREEPAGE: Number of pages to be loaded with data between each free page
Q121)What are simple, segmented andpartitioned table spaces ?
A121)Simple Tablespace: Can contain one or more tables.Rows from multiple tables can be interleaved on a page
under the DBA’s control and maintenance
Segmented Tablespace: Can contain one or more tables. Tablespace is divided into segments of 4 to 64 pages in
increments of 4 pages.Each segment is dedicated to single table.A table can occupy
Partitioned Tablespace: Can contain one table. Tablespace is divided into parts and each part is put in a separate
Q122)What is filter factor?
A122)One divided by the number of distinct values of a column.
Q123)What is index cardinality? - GS
A123)The number of distinct values a column or columns contain.
Q124)What is a synonym ?
A124)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.
Q125)What is the difference between SYNONYM and ALIAS?
A125)SYNONYM: is dropped when the table or tablespace is dropped. Synonym is available only to 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 information from
programs. Alias is a global object & is available to all.
Q126)What do you mean by NOT NULL WITH DEFAULT?When will you use it?
A126)This column cannot have nulls and while insertion, if no value is supplied then it will 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.
Q127)What do you mean by NOT NULL?When will you use it?
A127)The column cannot have nulls.Use it for key fields.
Q128)When would you prefer to use VARCHAR?
A128)When a column which contains long text, e.g. remarks, notes, may have in most cases less than 50% of the maximum length.
Q129)What are the disadvantages of using VARCHAR?
A129)Can lead to high space utilization if most of the values are close to maximum.
Positioning of VARCHAR column has to be done carefully as it has performance implications.
Relocation of rows to different pages can lead to more I/Os on retrieval.
Q130)How do I create a table MANAGER (EMP-NO, MANAGER) where MANAGER is a foreign key which references to EMP-NO in the same table?Give the exact DDL.
A130)First CREATE MANAGER table with EMP-NO as the primary key.Then ALTER it to define the foreign key.
Q131)When is the authorization check on DB2 objects done - at BIND time or run time?
A131)At run time.
Q132)What is auditing?
A132)Recording SQL statements that access a table.Specified at table creation time or through alter.
Q133)max number of columns in a db2 table
Q134)I need to view the number of tables existing under one particular Owner. Is it possible? If so, pl give the SQL query for this?
A134)The query SELECT * FROM SYSIBM.SYSTABLES WHERE CREATOR = 'owner id' This displays the table names with that If you want only the number of tables give the following query. SELECT COUNT(*) FROM SYSIBM.SYSTABLES WHERE CREATOR = 'owner id' Make sure that you are in correct subsystem.
Q135)I need to view the number of tables existing under one particular Owner. Is it possible? If so, pl give the SQL query for this?
A135)The query SELECT * FROM SYSTABLES WHERE OWNER= should work.
Q136)I need to view the number of tables existing under one particular Owner. Is it possible? If so, pl give the SQL query for this?
A136)Db2 records information for its operation in a catalog which is actually a group of tables. So we can use the SYSTABLES to get answer to ur query.
Q137)What is JOIN and different types of JOIN.
A137)The ability to join rows and combine data from two or more tables is one of the most powerful features of relational system. Three type of joins:1. Equi-join 2.Non-equijoin 3.self-join
Q138)can I alter a table (e.g. adding a column) when other user is selecting some columns or updating some columns from the same table?
A138)yes possible. until the updation or selection is committed db2 table will not be restructured. new column definition will be there but it will not be included until all the tasks on the table are committed.
Q139)How many sub queries can you combine together ?
A139)Total 16 queries and sub queries are 15
Q140)What are the different methods of accessing db2 from tso? How is the connection established between TSO & DB2?
A140)There are three ways in establishing tso/db2 connection 1. SPUFI 2. QMF 3. CATALOG VISIBILITY B. A thread between TSO & DB2 is established while attempting to make connection between tso & db2.
Q141)How many buffer pools are available in db2?
A141)Ten 32k size buffer pools and fifty 4k size buffer pools (bp0 to bp49)default buffer pools are bp0,bp1,bp2 & bp32
Q142)B37 abend during SPUFI
A142)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.
Q143)How many Buffer pools are there in DB2 and what are they?
A143)There are 4 Buffer pools. They are BP0,BP1,BP2 and BP32.
Q144)What is the command used by TSO users to invoke DB2?
Q145)What is the error code -803 ?
A145)unique index violation
Q146)How do you filter out the rows retrieved from a Db2 table ?
A146)one way is to use The SQL WHERE clause.
Q147)what is a collection?
A147)collection is something that every programmer should assign/Specify for every package. this about 1-18 characters long.
Q148)What is Skeleton cursor table (SKCT)?
A148)The Executable form of a Plan. This is stored in sysibm.sct02 table.
Q149)what's the equivalent Cobol Data type for Decimal(x,y) in DB2? what does the current SQLID register contain?
A149)Pic s9(x-y)V9(Y) Comp-3; the current SQLID contains the current authorization ID.
Q150)Can we declare DB2 HOST variable in COBOL COPY book?
A150)NO. If we declare DB2 host variable in COBOL COPY book, at the time of Pre-compilation we get the host variable not defined, because pre-compiler will not expand COBOL COPY book. So we declare it either in DCLGEN with EXEC SQL INCLUDE DCLGEN name END-EXEC or we directly hardcode it in the working storage section.
Q151)What should be specified along with a cursor in order to continue updating process after commit?
A151)With Hold option.
Q152)what is the name of the default db2 catalog database?
Q153)When Can you be sure that a query will return only one row?
A153)When you use the primary key and only the primary key in the where clause.
Q154)what is the difference between join and union?
A154)join is used to retrieve data from different tables using a single sql statement. union is used to combine the results of two or more sql queries.
Q155)What is a correlated sub query?
A155)In a sub query, if the outer query refers back to the outcome of inner query it is called correlated sub query. That's why the outer query is evaluated first unlike an ordinary sub query
Q156)What are the functions of Bind?
A156)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.
Q157)Max. No of rows per page
Q158)The only place of VSAM KSDS in DB2 is?
A158)BSDS is a VSAM KSDS.
Q159)Can All Users Have The Privilege To Use The SQL Statement Select * (DML)?
A159)No the user should be granted privilege to use it.
Q160)What is the size of a data page?
A160)4K to 8K
Q161)what's the best lock size that you could use when you create a tablespace?
A161)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.
Q162)what's the error code for Unique Index Violation?
Q163)Can you define an Index if the table size less than 10 PAGES?
Q164)What's the Maximum Length of SQLCA and what's the content of SQLCABC?
A164)The Max length is 136. and the SQLCABC has the Value of SQLCA.
Q165)What's the maximum number of volumes that can be added to a STOGROUP?
A165)The answer is 133.Usually it will be difficult monitor more than 3 or 4 volumes to a Stogroup.
Q166)What's the maximum number of characters that a tablename can have?
A166)The answer is 18 characters.
Q167)What is the meaning of -805 SQL return code?
A167)Program name not in plan. Bind the plan and include the DBRM for the program named as part of the plan.
Q168)when does the SQL statement gets executed when you use cursor in the application programming ?
A168)SQL statement gets executed when we open cursor
Q169)What does CURRENTDATA option in bind indicate
A169)CURRENTDATA 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(NO).
Q170)What is the difference between TYPE 1 index & TYPE 2 index
A170)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 retrieved faster as only the data pages are locked and not the index pages. Hence TYPE 2 index is recommended.
Q171)What are the levels of isolation available with DB2V4
A171)CS RR UR( added new for DB2V4 which stands for uncommitted read which allows to retrieve 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.
Q172)How do u achieve record level locking in DB2 versions when record level locking is not allowed?
A172)By having the length of the record greater than that of a page!
Q173)In a DB2-CICS program which is acts as co-ordinator and which is participant?
A173)DB2 - participant CICS- coordinator
Q174)What does DML stand for and what are some examples of it?
A174)Data Manipulation Language. Some examples are SELECT, INSERT, DELETE, REPLACE.
Q175)How to define the data items to receive the fetch items for the SQL?
A175)Using the DSECT, followed by lines of - 'data items DS datatype'.
Q176)How will you delete duplicate records from a table?
A176)Delete From Table1Where Id In (Select Id From Table1 As Temp Group By Id Having Count(*) >1)
Q177)What is the difference between Where and Having Clause
A177)WHERE is for Rows and HAVING is for Groups
Q178)How to see the structure of db2 table??
Q179)How do you declare a host variable (in COBOL) for an attribute named emp-name of type VARCHAR(25) ?
A179)01 EMP-GRP. 49 E-LEN PIC S9(4) COMP. 49 E-NAME PIC X(25).
Q180)What is the maximum number of tables that can be stored on a Partitioned Table Space ?
Q181)Name the different types of Table spaces.
A181)Simple Table Space, Segmented Table Space and Partitioned Table Space
Q182)what are the max. & min. no. of partitions allowed in a partition tablespace?
A182)minimum is 4. maximum is 64.
Q183)what is the maximum number of tables that can be joined ?
Q184)What technique is used to retrieve data from more than one table in a single SQL statement?
A184)The Join statement combines data from more that two tables
Q185)Explain the use of the WHERE clause.
A185)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.
Q186)What is a DB2 bind?
A186)DB2 bind is a process that builds an access path to DB2 tables.
Q187)What is a DB2 access path?
A187)An access path is the method used to access data specified in DB2 SQL statements.
Q188)What is a DB2 plan?
A188)An application plan or package is generated by the bind to define an access path.
Q189)What is normalization and what are the five normal forms?
A189)Normalization is a design procedure for representing data in tabular format.The five normal forms are progressive rules to represent the data with minimal redundancy.
Q190)What are foreign keys?
A190)These are attributes of one table that have matching values in a primary key in another table, allowing for relationships between tables.
Q191)Describe the elements of the SELECT query syntax?
A191)SELECT element FROM table WHERE conditional statement.
Q192)Explain the use of the WHERE clause?
A192)WHERE is used with a relational statement to isolate the object element or row.
Q193)What techniques are used to retrieve data from more than one table in a single SQL statement?
Mainframes - DB2 interview questions
The questions and answers that follow are intended for those with a working knowledge of DB2 as a “self-test”.