300+ [UPDATED] DB2 Using SQL Interview Questions

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

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

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

    Use SELECT COUNT(*) … in db2 query

  • PL/SQL Interview Questions

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

    Use SELECT DISTINCT … in db2 query

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

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

  • IBM DB2 Tutorial

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

    Use SELECT MAX(…) .. in db2 query

  • IBM DB2 Interview Questions

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

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

  • 7. What Are Aggregate Functions?

    Built-in mathematical functions for use in SELECT clause.

  • COBOL Tutorial Oracle Interview Questions

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

    YES.

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

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

  • COBOL Interview Questions

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

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

  • DB2 Using SQL Tutorial

  • 11. What Is The Use Of Value Function?

    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

  • 12. What Is Union,union All?

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

  • PL/SQL Interview Questions

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

    It has to be in a CURSOR.

  • IBM Mainframe Tutorial

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

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

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

    Yes.

  • MYSQL DBA Interview Questions

  • 16. 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.

  • IMS/DB Tutorial

  • 17. When Do You Use A Like Statement?

    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

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

    Match for any single character.

  • IBM DB2 Interview Questions

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

    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

  • 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?

    SELECT EMPNO
    FROM EMP
    WHERE PROJECT IS NULL;

  • IMS/DB Interview Questions

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

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

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

    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.
  • 23. What Are Correlated Subqueries?

    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

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

    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

  • 25. 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.

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

    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.

  • 27. What Happens When You Say Open Cursor?

    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

  • 28. Is Declare Cursor Executable?

    No.

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

    Yes.

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

    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.

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

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

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

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

  • IBM Mainframe Interview Questions

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

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

  • 35. What Is Dclgen

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

  • 36. What Are The Contents Of A Dclgen?

    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

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

    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.

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

    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.

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

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

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

    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

  • 41. Name Some Fields From Sqlca.

    SQLCODE, SQLERRM, SQLERRD

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

    Check the value stored in SQLERRD(3).


  • IMS/DB Interview Questions

  • 43. What Is Explain?

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

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

    Make sure that the PLAN_TABLE is created under the AUTHID.

  • 45. Where Is The Output Of Explain Stored?

    In userid.PLAN_TABLE

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

    A non matching index scan if ACCESSTYPE = I.

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

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

  • 48. What Are The Isolation Levels Possible ?

    CS: Cursor Stability
    RR: Repeatable Read

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

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

  • 50. Where Do You Specify Them ?

    ISOLATION LEVEL is a parameter for the bind process.

  • 51. What Are The Various Locking Levels Available?

    PAGE, TABLE, TABLESPACE

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

    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

  • 53. What Is Alter ?

    SQL command used to change the definition of DB2 objects.

  • 54. What Is A Dbrm, Plan ?

    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.

  • 55. What Is Acquire/release In Bind?

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

  • 56. 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

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

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

  • 58. What Are Packages ?

    They contain executable code for SQL statements for one DBRM.

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

    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.

  • 60. What Is A Collection?

    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.

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

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

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

    Print the output dataset.

  • 63. 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.

  • 64. What Is Dynamic Sql?

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

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

    At run time, when the PREPARE statement is issued.

  • 66. How Does Db2 Store Null Physically?

    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.

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

    Use null indicators. Syntax … INTO :HOSTVAR:NULLIND

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

    S9(4) COMP.

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

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

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

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

  • 71. What Is Runstats?

    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.

  • 72. When Will You Chose To Run Runstats?

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

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

    # 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

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

    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.

  • 75. What Is Copy Pending Status?

    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.

  • 76. What Is Check Pending ?

    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.

  • 77. What Is Quiesce?

    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.

  • 78. What Is A Clustering Index ?

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

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

    Only one.

  • 80. 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.

  • 81. What Is Sqlcode -922 ?

    Authorization failure

  • 82. What Is Sqlcode -811?

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

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

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

  • 84. Are Views Updateable?

    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.

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

    No.

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

    TSO, CICS, IMS and BATCH

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

    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.

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

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

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

    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.
  • 90. What Is Index Cardinality?

    The number of distinct values a column or columns contain.

  • 91. What Is A Synonym ?

    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.

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

    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.

  • 93. 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 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.

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

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

  • 95. When Would You Prefer To Use Varchar?

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

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

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

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

    At run time.

  • 98. What Is Auditing?

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

  • 99. What Is An Access Path?

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

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

  • 101. Explain What A Plan Is?

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

  • 102. What Is A Db2 Bind?

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

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

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

  • 104. What Is Meant By The Attachment Facility?

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

  • 105. What Is Meant By Auto Commit?

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

  • 106. What Is A Base Table?

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

  • 107. What Is The Function Of Buffer Manager?

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

  • 108. What Is A Buffer Pool?

    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.

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

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

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

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

  • 111. What Is A Clustering Index?

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

  • 112. What Will The Commit Accomplish?

    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.

  • 113. What Is Meant By Concurrency?

    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.

  • 114. What Is Cursor Stability?

    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.

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

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

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

    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.

  • 117. What Is A Data Page?

    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.

  • 118. What Are Data Types?

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

  • 119. What Is Declaration Generator(dclgen)?

    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.

  • 120. What Does Dsndb07 Database Do?

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

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

    It will drop(delete) that existing plan.

  • 122. What Is A Host Variable?

    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.

  • 123. What Will The Db2 Optimizer Do?

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

  • 124. What Is A Page?

    Answer :

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

  • 125. What Is Pagespace?

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

  • 126. What Is A Predicate?

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

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

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

  • 128. Where Are Plans Stored?

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

  • 129. What Is Meant By Repeatable Read?

    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.

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

    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.

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

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

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

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

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

    No

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

    Exclusive, update, and share.

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

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

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

    Asynchronously.

  • 137. What Is A Db2 Catalog?

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

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

    In the RECLENGTH column of SYSIBM.SYSTABLES

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

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

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

    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?

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

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

    SYSIBM.SYSDBAUTH

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

    This information can be found in SYSIBM.SYSINDEXES.

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

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

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

    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.

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

    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

  • 147. Correlated Sub Query?

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

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

    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?

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

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

      //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  /*  

  • 151. How To Eliminate Duplicate Records Except One

      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’);

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

    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;

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

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

  • 154. How To Find N Th Max Or Min

    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)

  • 155. What Is Tsq And Tdq?

    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.