DB2 Using SQL Interview Questions & Answers

  • Question 1. What Is Db2 (ibm Database 2)?

    Answer :

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

  • Question 2. How Would You Find Out The Total Number Of Rows In A Db2 Table?

    Answer :

    Use SELECT COUNT(*) … in db2 query

  • PL/SQL Interview Questions

  • Question 3. How Do You Eliminate Duplicate Values In Db2 Select ?

    Answer :

    Use SELECT DISTINCT … in db2 query

  • Question 4. How Do You Select A Row Using Indexes In Db2?

    Answer :

    Specify the indexed columns in the WHERE clause of db2 query.

  • IBM DB2 Tutorial

  • Question 5. How Do You Find The Maximum Value In A Column In Db2?

    Answer :

    Use SELECT MAX(…) .. in db2 query

  • IBM DB2 Interview Questions

  • Question 6. How Do You Retrieve The First 5 Characters Of Firstname Column Of Db2 Table Emp ?

    Answer :

    SQL Query : SELECT SUBSTR(FIRSTNAME,1,5) FROM EMP;

  • Question 7. What Are Aggregate Functions?

    Answer :

    Built-in mathematical functions for use in SELECT clause.

  • COBOL Tutorial Oracle Interview Questions

  • Question 8. Can You Use Max On A Char Column?

    Answer :

    YES.

  • Question 9. My Sql Statement Select Avg(salary) From Emp Yields Inaccurate Results. Why?

    Answer :

    Because SALARY is not declared to have NULLs and the employees for whom the salary is not known are also counted.

  • COBOL Interview Questions

  • Question 10. How Do You Concatenate The Firstname And Lastname From Emp Table To Give A Complete Name?

    Answer :

    SELECT FIRSTNAME || ‘ ‘ || LASTNAME FROM EMP;

  • DB2 Using SQL Tutorial

  • Question 11. What Is The Use Of Value Function?

    Answer :

    1. Avoid -ve SQLCODEs by handling nulls and zeroes in computations
    2. Substitute a numeric value for any nulls used in computation

  • IBM Mainframe Interview Questions

  • Question 12. What Is Union,union All?

    Answer :

    UNION : eliminates duplicates
    UNION ALL: retains duplicates
    Both these are used to combine the results of different SELECT statements.

  • PL/SQL Interview Questions

  • Question 13. What Is The Restriction On Using Union In Embedded Sql?

    Answer :

    It has to be in a CURSOR.

  • IBM Mainframe Tutorial

  • Question 14. In The Where Clause What Is Between And In?

    Answer :

    BETWEEN supplies a range of values while IN supplies a list of values.

  • Question 15. Is Between Inclusive Of The Range Values Specified?

    Answer :

    Yes.

  • MYSQL DBA Interview Questions

  • Question 16. What Is ‘like’ Used For In Where Clause? What Are The Wildcard Characters?

    Answer :

    LIKE is used for partial string matches. ‘%’ ( for a string of any character ) and ‘_’ (for any single character ) are the two wild card characters.

  • IMS/DB Tutorial

  • Question 17. When Do You Use A Like Statement?

    Answer :

    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.

  • DB2 SQL Programming Interview Questions

  • Question 18. What Is The Meaning Of Underscore ( ‘-‘ ) In The Like Statement?

    Answer :

    Match for any single character.

  • IBM DB2 Interview Questions

  • Question 19. What Do You Accomplish By Group By … Having Clause?

    Answer :

    GROUP BY partitions the selected rows on the distinct values of the column on which you group by.
    HAVING selects GROUPs which match the criteria specified

  • Question 20. Consider The Employee Table With Column Project Null Able. How Can You Get A List Of Employees Who Are Not Assigned To Any Project?

    Answer :

    SELECT EMPNO
    FROM EMP
    WHERE PROJECT IS NULL;

  • IMS/DB Interview Questions

  • Question 21. What Is The Result Of This Query If No Rows Are Selected:

    Answer :

    SELECT SUM(SALARY)
    FROM EMP
    WHERE QUAL=‘MSC’;
    NULL

  • Question 22. Why Select * Is Not Preferred In Embedded Sql Programs?

    Answer :

    For three reasons:

    • 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.
    • The chance of an index only scan is lost.
  • Question 23. What Are Correlated Subqueries?

    Answer :

    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.

  • Mainframe DB2 Interview Questions

  • Question 24. What Is A Cursor? Why Should It Be Used?

    Answer :

    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.

  • Oracle Interview Questions

  • Question 25. How Would You Retrieve Rows From A Db2 Table In Embedded Sql?

    Answer :

    Either by using the single row SELECT statements, or by using the CURSOR.

  • Question 26. How Do You Specify And Use A Cursor In A Cobol Program?

    Answer :

    Use DECLARE CURSOR statement either in working storage or in procedure division(before open cursor), to specify the SELECT statement. Then use OPEN, FETCH rows in a loop and finally CLOSE.

  • Question 27. What Happens When You Say Open Cursor?

    Answer :

    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.

  • COBOL Interview Questions

  • Question 28. Is Declare Cursor Executable?

    Answer :

    No.

  • Question 29. Can You Have More Than One Cursor Open At Any One Time In A Program?

    Answer :

    Yes.

  • Question 30. When You Commit, Is The Cursor Closed?

    Answer :

    Yes.

  • Question 31. How Do You Leave The Cursor Open After Issuing A Commit? ( For Db2 2.3 Or Above Only )

    Answer :

    Use WITH HOLD option in DECLARE CURSOR statement. But, it has not effect in psuedo-conversational CICS programs.

  • Question 32. What Is The Physical Storage Length Of Each Of The Following Db2 Data Types: Date, Time, Timestamp?

    Answer :

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

  • Question 33. What Is The Cobol Picture Clause Of The Following Db2 Data Types: Date, Time, Timestamp?

    Answer :

    DATE: PIC X(10)
    TIME : PIC X(08)
    TIMESTAMP: PIC X(26)

  • IBM Mainframe Interview Questions

  • Question 34. What Is The Cobol Picture Clause For A Db2 Column Defined As Decimal(11,2)?

    Answer :

    PIC S9(9)V99 COMP-3.
    Note: In DECIMAL(11,2), 11 indicates the size of the data type and 2 indicates the precision.

  • Question 35. What Is Dclgen

    Answer :

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

  • Question 36. What Are The Contents Of A Dclgen?

    Answer :

    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.
  • MYSQL DBA Interview Questions

  • Question 37. Is It Mandatory To Use Dclgen? If Not, Why Would You Use It At All?

    Answer :

    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.

  • Question 38. Is Declare Table In Dclgen Necessary? Why It Used?

    Answer :

    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.

  • Question 39. Will Precompile Of An Db2-cobol Program Bomb, If Db2 Is Down?

    Answer :

    No. Because the precompiler does not refer to the DB2 catalogue tables.

  • Question 40. How Is A Typical Db2 Batch Program Executed ?

    Answer :

    1. Use DSN utility to run a DB2 batch program from native TSO.

    An example is shown:
    DSN SYSTEM(DSP3)
    RUN PROGRAM(EDD470BD) PLAN(EDD470BD) LIB(‘ED 01T.OBJ.LOADLIB’)
    END
    2. Use IKJEFT01 utility program to run the above DSN command in a JCL.

  • DB2 SQL Programming Interview Questions

  • Question 41. Name Some Fields From Sqlca.

    Answer :

    SQLCODE, SQLERRM, SQLERRD

  • Question 42. How Can You Quickly Find Out The # Of Rows Updated After An Update Statement?

    Answer :

    Check the value stored in SQLERRD(3).


  • IMS/DB Interview Questions

  • Question 43. What Is Explain?

    Answer :

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

  • Question 44. What Do You Need To Do Before You Do Explain?

    Answer :

    Make sure that the PLAN_TABLE is created under the AUTHID.

  • Question 45. Where Is The Output Of Explain Stored?

    Answer :

    In userid.PLAN_TABLE

  • Question 46. Explain Has Output With Matchcols = 0. What Does It Mean?

    Answer :

    A non matching index scan if ACCESSTYPE = I.

  • Question 47. How Do You Do The Explain Of A Dynamic Sql Statement?

    Answer :

    1. Use SPUFI or QMF to EXPLAIN the dynamic SQL statement
    2. Include EXPLAIN command in the embedded dynamic SQL statements

  • Question 48. What Are The Isolation Levels Possible ?

    Answer :

    CS: Cursor Stability
    RR: Repeatable Read

  • Question 49. What Is The Difference Between Cs And Rr Isolation Levels?

    Answer :

    CS: Releases the lock on a page after use
    RR: Retains all locks acquired till end of transaction

  • Question 50. Where Do You Specify Them ?

    Answer :

    ISOLATION LEVEL is a parameter for the bind process.

  • Question 51. What Are The Various Locking Levels Available?

    Answer :

    PAGE, TABLE, TABLESPACE

  • Question 52. How Does Db2 Determine What Lock-size To Use?

    Answer :

    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 chooses a lock-size of PAGE

  • Question 53. What Is Alter ?

    Answer :

    SQL command used to change the definition of DB2 objects.

  • Question 54. What Is A Dbrm, Plan ?

    Answer :

    DBRM: Data Base 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.

  • Question 55. What Is Acquire/release In Bind?

    Answer :

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

  • Question 56. What Else Is There In The Plan Apart From The Access Path?

    Answer :

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

  • Question 57. What Happens To The Plan If Index Used By It Is Dropped?

    Answer :

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

  • Question 58. What Are Packages ?

    Answer :

    They contain executable code for SQL statements for one DBRM.

  • Question 59. What Are The Advantages Of Using A Package?

    Answer :

    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.

  • Question 60. What Is A Collection?

    Answer :

    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.

  • Question 61. What Are The 2 Sqlcodes That Are Returned?

    Answer :

    100 ( for successful completion of the query ), 0 (for successful COMMIT if AUTOCOMMIT is set to Yes).

  • Question 62. How Would You Print The Output Of An Sql Statement From Spufi?

    Answer :

    Print the output dataset.

  • Question 63. Lot Of Updates Have Been Done On A Table Due To Which Indexes Have Gone Haywire. What Do You Do?

    Answer :

    Looks like index page split has occurred. DO a REORG of the indexes.

  • Question 64. What Is Dynamic Sql?

    Answer :

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

  • Question 65. When Is The Access Path Determined For Dynamic Sql?

    Answer :

    At run time, when the PREPARE statement is issued.

  • Question 66. How Does Db2 Store Null Physically?

    Answer :

    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.

  • Question 67. How Do You Retrieve The Data From A Nullable Column?

    Answer :

    Use null indicators. Syntax … INTO :HOSTVAR:NULLIND

  • Question 68. What Is The Picture Clause Of The Null Indicator Variable?

    Answer :

    S9(4) COMP.

  • Question 69. What Does It Mean If The Null Indicator Has -1, 0, -2?

    Answer :

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

  • Question 70. How Do You Insert A Record With A Nullable Column?

    Answer :

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

  • Question 71. What Is Runstats?

    Answer :

    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.

  • Question 72. When Will You Chose To Run Runstats?

    Answer :

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

  • Question 73. Give Some Example Of Statistics Collected During Runstats?

    Answer :

    # of rows in the table
    Percent of rows in clustering sequence
    # of distinct values of indexed column
    # of rows moved to a nearby/far way page due to row length increase

  • Question 74. What Is Reorg? When Is It Used?

    Answer :

    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 deletes activity and after segments of a segmented tablespace have become fragmented.

  • Question 75. What Is Copy Pending Status?

    Answer :

    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.

  • Question 76. What Is Check Pending ?

    Answer :

    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.

  • Question 77. What Is Quiesce?

    Answer :

    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.

  • Question 78. What Is A Clustering Index ?

    Answer :

    Causes the data rows to be stored in the order specified in the index. A mandatory index defined on a partitioned table space.

  • Question 79. How Many Clustering Indexes Can Be Defined For A Table?

    Answer :

    Only one.

  • Question 80. What Is The Difference Between Primary Key & Unique Index ?

    Answer :

    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.

  • Question 81. What Is Sqlcode -922 ?

    Answer :

    Authorization failure

  • Question 82. What Is Sqlcode -811?

    Answer :

    SELECT statement has resulted in retrieval of more than one row.

  • Question 83. What Does The Sqlcode Of -818 Pertain To?

    Answer :

    This is generated when the consistency tokens in the DBRM and the load module are different.

  • Question 84. Are Views Updateable?

    Answer :

    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.

  • Question 85. If I Have A View Which Is A Join Of Two Or More Tables, Can This View Be Updateable?

    Answer :

    No.

  • Question 86. What Are The 4 Environments Which Can Access Db2 ?

    Answer :

    TSO, CICS, IMS and BATCH

  • Question 87. What Is An Inner Join, And An Outer Join ?

    Answer :

    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. These kinds 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.

  • Question 88. What Is Freepage And Pctfree In Tablespace Creation?

    Answer :

    PCTFREE: percentage of each page to be left free
    FREEPAGE: Number of pages to be loaded with data between each free page

  • Question 89. What Are Simple, Segmented And Partitioned Table Spaces ?

    Answer :

    Simple Tablespace:

    • Can contain one or more tables
    • Rows from multiple tables can be interleaved on a page under the DBAs 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 multiple segments.

    Partitioned Tablespace:

    • Can contain one table
    • Tablespace is divided into parts and each part is put in a separate VSAM dataset.
  • Question 90. What Is Index Cardinality?

    Answer :

    The number of distinct values a column or columns contain.

  • Question 91. What Is A Synonym ?

    Answer :

    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.

  • Question 92. What Is The Difference Between Synonym And Alias?

    Answer :

    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 info from programs. Alias is a global object & is available to all.

  • Question 93. What Do You Mean By Not Null With Default? When Will You Use It?

    Answer :

    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.

  • Question 94. What Do You Mean By Not Null? When Will You Use It?

    Answer :

    The column cannot have nulls. Use it for key fields.

  • Question 95. When Would You Prefer To Use Varchar?

    Answer :

    When a column which contains long text, e.g. remarks, notes, may have in most cases less than 50% of the maximum length.

  • Question 96. How Do I Create A Table Manager ( Emp#, Manager) Where Manager Is A Foreign Key Which References To Emp# In The Same Table? Give The Exact Ddl.

    Answer :

    First CREATE MANAGER table with EMP# as the primary key. Then ALTER it to define the foreign key.

  • Question 97. When Is The Authorization Check On Db2 Objects Done – At Bind Time Or Run Time?

    Answer :

    At run time.

  • Question 98. What Is Auditing?

    Answer :

    Recording SQL statements that access a table . specified at table creation time or through alter.

  • Question 99. What Is An Access Path?

    Answer :

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

  • Question 100. What Is An Alias?

    Answer :

    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.

  • Question 101. Explain What A Plan Is?

    Answer :

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

  • Question 102. What Is A Db2 Bind?

    Answer :

    Bind is a process that 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).

  • Question 103. What Information Is Used As Input To The Bind Process?

    Answer :

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

  • Question 104. What Is Meant By The Attachment Facility?

    Answer :

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

  • Question 105. What Is Meant By Auto Commit?

    Answer :

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

  • Question 106. What Is A Base Table?

    Answer :

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

  • Question 107. What Is The Function Of Buffer Manager?

    Answer :

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

  • Question 108. What Is A Buffer Pool?

    Answer :

    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.

  • Question 109. How Many Buffer Pools Are There In Db2?

    Answer :

    There are four buffer pools: BP0, BP1, BP2, and BP32.

  • Question 110. On The Create Tablespace, What Does The Close Parameter Do?

    Answer :

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

  • Question 111. What Is A Clustering Index?

    Answer :

    It is a type of index that (1) locates table rows and (2) determines how rows are grouped together in the tablespace

  • Question 112. What Will The Commit Accomplish?

    Answer :

    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.

  • Question 113. What Is Meant By Concurrency?

    Answer :

    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.

  • Question 114. What Is Cursor Stability?

    Answer :

    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.

  • Question 115. What Is The Function Of The Data Manager?

    Answer :

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

  • Question 116. What Is A Database Req
    uest Module(dbrm)?

    Answer :

    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.

  • Question 117. What Is A Data Page?

    Answer :

    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.

  • Question 118. What Are Data Types?

    Answer :

    They are attributes of columns, literals, and host variables. The data types are SMALLINT, INTEGER, FLOAT, DECIMAL, CHAR, VARCHAR, DATE and TIME.

  • Question 119. What Is Declaration Generator(dclgen)?

    Answer :

    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.

  • Question 120. What Does Dsndb07 Database Do?

    Answer :

    DSNDB07 is where DB2 does its sorting. It includes DB2’s sort work area and external storage

  • Question 121. What Will The Free Command Do To A Plan?

    Answer :

    It will drop(delete) that existing plan.

  • Question 122. What Is A Host Variable?

    Answer :

    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.

  • Question 123. What Will The Db2 Optimizer Do?

    Answer :

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

  • Question 124. What Is A Page?

    Answer :

    This is the unit of storage within a table space or indexspace that is accessed by DB2.

  • Question 125. What Is Pagespace?

    Answer :

    Pagespace refers to either to an unpartitioned table, to an index space, or to a single partition of a partitioned table of index space.

  • Question 126. What Is A Predicate?

    Answer :

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

  • Question 127. What Is A Resource Control Table(rct)? Describe Its Characteristics.

    Answer :

    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 ID andplan ID(CICS attachment facility).

  • Question 128. Where Are Plans Stored?

    Answer :

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

  • Question 129. What Is Meant By Repeatable Read?

    Answer :

    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.

  • Question 130. Describe What A Storage Group(stogroup) Is?

    Answer :

    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.

  • Question 131. What Is The Format (internal Layout) Of “timestamp”?

    Answer :

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

  • Question 132. What Is Meant By A Unit Of Recovery?

    Answer :

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

  • Question 133. Can Dasd Types Assigned To Storage Groups Be Intermixed(i.e., 3350s And 3380s)?

    Answer :

    No

  • Question 134. What Are The Three Types Of Page Locks That Can Be Held?

    Answer :

    Exclusive, update, and share.

  • Question 135. Can Db2 Be Accessed By Tso Users? If Yes, Which Command Is Used To Invoke Db2?

    Answer :

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

  • Question 136. How Are Write I/os From The Buffer Pool Executed?

    Answer :

    Asynchronously.

  • Question 137. What Is A Db2 Catalog?

    Answer :

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

  • Question 138. In Which Column Of Which Db2 Catalog Would You Find The Length Of The Rows For All Tables?

    Answer :

    In the RECLENGTH column of SYSIBM.SYSTABLES

  • Question 139. What Information Is Held In Sysibm.syscopy?

    Answer :

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

  • Question 140. What Information Is Contained In A Syscopy Entry?

    Answer :

    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.

  • Ques
    tion 141. What Information Can You Find In Sysibm.syslinks Table?

    Answer :

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

  • Question 142. Where Would You Find Information About The Type Of Database Authority Held By The User?

    Answer :

    SYSIBM.SYSDBAUTH

  • Question 143. Where Could You Look If You Had A Question About Whether A Column Has Been Defined As An Index?

    Answer :

    This information can be found in SYSIBM.SYSINDEXES.

  • Question 144. Once You Create A View, Where Would Information About The View Be Stored?

    Answer :

    When a view is created, system information about the view is stored in SYSIBM.SYSVIEWS.

  • Question 145. What Is The Sql Communications Area And What Are Some Of Its Key Fields?

    Answer :

    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.

  • Question 146. How To Get The Value With Leading Zeros?

    Answer :

    SELECT POLICY_NUMBER, DIGITS (BASE_PREM_TOT)
    FROM DB2K.CGIST.TW4T0
    If the value of BASE_PREM_TOT is 472.00 then it will be selected as like this 00000047200

  • Question 147. Correlated Sub Query?

    Answer :

    SELECT A.DRIVER_REFERENCE
    FROM CGDEV4.TU4ML A
    WHERE A.LICENSE_NUMBER = ‘POTAPA*355B2’ AND
    A.DRIVER_REFERENCE =
    (SELECT C.CLIENT_REFERENCE
    FROM CGDEV4.TZ1SR C
    WHERE A.DRIVER_REFERENCE = C.CLIENT_REFERENCE AND
    SUBSTR(C.Z_UPPER_FIRST_NAME,1,1) = ‘A’ AND
    SUBSTR(C.Z_UPPER_LAST_NAME,1,3) = ‘JZB’)

  • Question 148. How To Delete Duplicated Based On Certain Column Retaining One

    Answer :

    DELETE FROM TABLE1 A WHERE A.PRIMARYKEY<>(SELECT MIN(PRIMARYKEY) FROM TZCHC B
    WHERE A.COLUMN1= B.COLUMN1);

  • Question 149. How To Count Occurrence Of Letter In A String?

    Answer :

    SELECT (LENGTH(‘SUBASH’) – LENGTH(REPLACE(‘SUBASH’,’S’,”))) AS S_COUNT FROM SYSIBM.SYSDUMMY1

  • Question 150. How To Execute The Sql Through Jcl Using Utility

    Answer :

      //CREATE EXEC PGM=IKJEFT01,DYNAMNBR=20  //SYSTSPRT DD SYSOUT=*  //SYSPRINT DD SYSOUT=*  //SYSTSIN DD *  DSN SYSTEM(DB2T)  RUN PROGRAM(DSNTEP2) PLAN(DSNTEP2) LIB('DB2T.RUNLIB.LOAD')  END  /*  //SYSIN DD *  SELECT COUNT(USER_UPDATED)  FROM CGDEV4.TWC39  WHERE USER_UPDATED='DPPLSPP'  GROUP BY USER_UPDATED  /*  

  • Question 151. How To Eliminate Duplicate Records Except One

    Answer :

      DELETE FROM TZCHC TD1  WHERE HOLIDAY_DATE<> (SELECT MIN (HOLIDAY_DATE)  FROM TZCHC TD2  WHERE TD1.LONG_DESC = TD2.LONG_DESC  AND TD2.LONG_DESC = 'CHRISTMAS DAY’);

  • Question 152. How To Subtract The Years, Months And Days Separately From Date

    Answer :

    SELECT DATE (‘2003-10-13′) – DEC (’03’) YEARS – DEC (’07’) MONTHS – DEC (’13’) DAYS FROM SYSIBM.SYSDUMMY1;

    SELECT DATE (‘2003-10-13’) – DEC (‘2000’) YEARS –
    DEC (’27’) MONTHS – DEC (’45’) DAY
    FROM SYSIBM.SYSDUMMY1;

  • Question 153. How To Get The Max Count When Group By Some Other Field

    Answer :

      SELECT USER_UPDATED, COUNT (USER_UPDATED) AS COUNT1  FROM CGDEV4.TWC39  GROUP BY USER_UPDATED  HAVING COUNT (USER_UPDATED) >= ALL  (SELECT COUNT (USER_UPDATED)  FROM CGDEV4.TWC39  GROUP BY USER_UPDATED);  

  • Question 154. How To Find N Th Max Or Min

    Answer :

    SELECT DISTINCT A.TIMESTAMP_UPDATED, A.USER_UPDATED
    FROM CGDEV4.TWC39 A
    WHERE 5 =
    (SELECT COUNT (DISTINCT B.TIMESTAMP_UPDATED)
    FROM CGDEV4.TWC39 B
    WHERE B.TIMESTAMP_UPDATED >= A.TIMESTAMP_UPDATED)

  • Question 155. What Is Tsq And Tdq?

    Answer :

    TSQ:

    • Its like a scratch pad, This will not go to permanent memory unless you explicitly specify.
    • This is used if you have page up/page down logic in your CICS screens.
    • Program A calling Program B which selects db2 rows, So in program B you can write all your rows fetched to a TSQ and come back to program A, now you can read these rows from TSQ rather than going to Db2 every time.
    • If you have large amount of data to be passed between to tasks of a transaction you can use TSQ.

    TDQ:

    • If you want some processing should happen depending on the data that you have read from the screen for example. user wants to print the screen, take the information write it to a TDQ this will trigger a transaction which does the printing.
    • Trigger level tells and indicates, after nth record is written to a TDQ it should trigger the transaction associated with it.
    • TDQ has to be defined prior to use.