|DB2 Interview questions and answers
Q1: What is ALTER?
ALTER is an SQL statement that is used to change the structure of any objects like table structure, add any field, etc.
Q2: What are some of the main fields in SQLCA?
There are various fields in SQLCA. Some are SQLCAID, SQLCODE which contain the error code.
Q3: What is the physical storage length of each of the data types DATE, TIME, and TIMESTAMP?
The physical storage length of each of the data types DATE, TIME, and TIMESTAMP are 4 bytes, 3 bytes, and 10 bytes.
Q4: Can there be more than one cursor open for any program?
Yes, there can be more than one cursor open for any program.
Q5: What is the result of the OPEN CURSOR statement?
The OPEN CURSOR statement opens a cursor that is used to fetch rows from its result table and it sets the pointer to the first record of the table from where the records have to process one by one.
Q6: Is there any restriction on the use of UNION embedded SQL?
Yes, there is a restriction that UNION can only be used in a cursor when its being used as embedded SQL in an RPG program.
Q7: What are UNION and UNION ALL?
UNION and UNION ALL are SQL operators used to concatenate 2 or more result sets where UNION selects only unique records and UNION ALL keeps all records, including duplicates.
Q8: Is it possible to use MAX on a CHAR column?
Q9: How can the duplicate values be eliminated from DB2 SELECT?
Using SELECT DISTINCT to eliminate duplicate rows and that would be applicable to all columns.
Q10: How to find the number of rows in a DB2 table?
The COUNT (*) function is used to find the number of rows in a DB2 table.