MCQs > IT & Programming > DB2 Programming MCQs > Basic DB2 Programming MCQs

Basic DB2 Programming MCQ

1. Is DECLARE TABLE in DCLGEN necessary?


Answer

Correct Answer: Yes

Note: This Question is unanswered, help us to find answer for this one

2. What is the purpose of the WHENEVER statement?


Answer

Correct Answer: It is used to control program actions depending on the SQL-CODE

Note: This Question is unanswered, help us to find answer for this one

3. Consider the employee table with column MGR nullable. How can you get a list of employees who are not assigned to any mgr?


Answer

Correct Answer:

SELECT EMPNO FROM EMP

WHERE MGR IS NULL;


Note: This Question is unanswered, help us to find answer for this one

4. What are the advantages of using a PACKAGE?


Answer

Correct Answer: Cost of a large bind can be avoided

Note: This Question is unanswered, help us to find answer for this one

5. What does DBRM Stand for?


Answer

Correct Answer: DataBase Resource Manager

Note: This Question is unanswered, help us to find answer for this one

6. What is returned by the VALUE function?


Answer

Correct Answer: It returns the first argument that is not null.

Note: This Question is unanswered, help us to find answer for this one

7. When would you choose to run RUNSTATS?


Answer

Correct Answer: All of the above 

Note: This Question is unanswered, help us to find answer for this one

8. What is a subselect?


Answer

Correct Answer: A select which works in conjunction with another select

Note: This Question is unanswered, help us to find answer for this one

9. What are the disadvantages of PAGE level lock?


Answer

Correct Answer: High resource utilization if large updates are to be done

Note: This Question is unanswered, help us to find answer for this one

10. When you COMMIT, is the cursor closed?


Answer

Correct Answer: Yes

Note: This Question is unanswered, help us to find answer for this one

11. What are the various locks available?


Answer

Correct Answer: All of the above 

Note: This Question is unanswered, help us to find answer for this one

12. What should be done before you do EXPLAIN?


Answer

Correct Answer: PLAN_TABLE should be created under the AUTHID

Note: This Question is unanswered, help us to find answer for this one

13. If the null indicator has -1, what does it mean?


Answer

Correct Answer: the field is null

Note: This Question is unanswered, help us to find answer for this one

14. Which technique is used to retrieve data from more than one table in a single SQL statement?


Answer

Correct Answer: Join

Note: This Question is unanswered, help us to find answer for this one

15. How do you concatenate the FIRSTNAME and LASTNAME from EMPLOYEE table to give a complete name?


Answer

Correct Answer: SELECT FIRSTNAME || ' ' || LASTNAME FROM EMPLOYEE;

Note: This Question is unanswered, help us to find answer for this one

16. How would you retrieve the first 5 characters of FIRSTNAME column of DB2 table EMP?


Answer

Correct Answer: SELECT SUBSTR(FIRSTNAME,1,5) FROM EMP;

Note: This Question is unanswered, help us to find answer for this one

17. When do you specify the isolation level?


Answer

Correct Answer: During the BIND process

Note: This Question is unanswered, help us to find answer for this one

18. How do you leave the cursor open after issuing a COMMIT?


Answer

Correct Answer: By using WITH HOLD option

Note: This Question is unanswered, help us to find answer for this one

19. Can you have more than one cursor open at any one time in a program?  


Answer

Correct Answer: Yes

Note: This Question is unanswered, help us to find answer for this one

20. Suppose there is a cobol-db2 program. If you have  made changes only in the cobol program, is there a need to recomile the DBRM?


Answer

Correct Answer: Yes

Note: This Question is unanswered, help us to find answer for this one

21. What is the meaning of underscore ( '_' ) in the LIKE statement?


Answer

Correct Answer: It is a match for any single character

Note: This Question is unanswered, help us to find answer for this one

22. What are correlated subqueries?


Answer

Correct Answer: It is a subquery in which the inner ( nested ) query refers back to the table in the outer query

Note: This Question is unanswered, help us to find answer for this one

23. What is the use of FREE command?


Answer

Correct Answer: It is used to delete Plan

Note: This Question is unanswered, help us to find answer for this one

24. How would you find out the total number of rows in a DB2 table?


Answer

Correct Answer: Using SELECT COUNT(*)

Note: This Question is unanswered, help us to find answer for this one

25. State whether true or false.
When you open a cursor, DB2 will always get all rows that meet the selection criteria and create a result set.


Answer

Correct Answer: True

Note: This Question is unanswered, help us to find answer for this one

26. Why is SELECT * not preferred in embedded SQL programs?


Answer

Correct Answer: If the table structure is changed, the program will have to be modified

Note: This Question is unanswered, help us to find answer for this one

27. What is the restriction on using UNION in embedded SQL?


Answer

Correct Answer: It has to be in a CURSOR

Note: This Question is unanswered, help us to find answer for this one

28. What is the difference between QMF & SPUFI?


Answer

Correct Answer: You can know sqlcode after excuting the code in QMF. In SPUFI, it is not possible

Note: This Question is unanswered, help us to find answer for this one

29. What is a thread?


Answer

Correct Answer: It is a connection between DB2 and some other subsystem

Note: This Question is unanswered, help us to find answer for this one

30. When will you use curser with hold option?


Answer

Correct Answer: When you are using commit with in the cursor

Note: This Question is unanswered, help us to find answer for this one

31. What is the statistics collected during RUNSTATS?


Answer

Correct Answer: Number of distinct values of indexed column

Note: This Question is unanswered, help us to find answer for this one

32. Under which circumstance would you create an index on a table?


Answer

Correct Answer: When two columns are consistently used in the WHERE clause join condition of SELECT statements 

Note: This Question is unanswered, help us to find answer for this one

33. How can you quickly find out the number of rows updated after an update statement?


Answer

Correct Answer: Check the value stored in SQLERRD(3)

Note: This Question is unanswered, help us to find answer for this one

34. What are the disadvantages of using VARCHAR?


Answer

Correct Answer: It can lead to high space utilization if most of the values are close to maximum

Note: This Question is unanswered, help us to find answer for this one

35. How would you display the table definitions (columns, data types of columns, constraints or default values set etc) of a table in QMF?


Answer

Correct Answer: SELECT * FROM SYSIBM.SYSCOLUMNS WHERE TBNAME=table-name AND TBCREATOR=' creator-name';

Note: This Question is unanswered, help us to find answer for this one

36. Can GROUP BY and ORDER BY used in a single query?


Answer

Correct Answer: Yes

Note: This Question is unanswered, help us to find answer for this one

37. What happens when you say OPEN CURSOR?


Answer

Correct Answer: The cursor is placed on the first row

Note: This Question is unanswered, help us to find answer for this one

38. What are the various locking levels available?


Answer

Correct Answer: All of the above 

Note: This Question is unanswered, help us to find answer for this one

39. How does DB2 determine which lock-size to use?


Answer

Correct Answer: DB2 determines it based on the given lock-size while creating the tablespace

Note: This Question is unanswered, help us to find answer for this one

40. Can you use MAX on a CHAR column?


Answer

Correct Answer: Yes

Note: This Question is unanswered, help us to find answer for this one

41. When can you not drop a database

Answer

Correct Answer: When a DB2 utility has control of any part of the database.

Note: This Question is unanswered, help us to find answer for this one

42. In what form is data physically stored in DB2

Answer

Correct Answer: VSAM LDS

Note: This Question is unanswered, help us to find answer for this one

43. Consider the following embedded SQL statement: SELECT CLASSNAME INTO :CLASSNAME:IND FROM CLASS WHERE STUDNAME = :STUDNAME In which order should the following program variables be evaluated by the part of the program just after this SQL statement?

Answer

Correct Answer: SQLCODE, IND, CLASSNAME

Note: This Question is unanswered, help us to find answer for this one

44. Which of the following is not a type of dynamic SQL?

Answer

Correct Answer: Enhanced PL/SQL

Note: This Question is unanswered, help us to find answer for this one

45. When using JBDC, do you have to recode your Java application if you want to change between drivers?

Answer

Correct Answer: No.

Note: This Question is unanswered, help us to find answer for this one

46. Which of the following represents a function that is performed for each row in a DB2 table

Answer

Correct Answer: Scalar function

Note: This Question is unanswered, help us to find answer for this one

47. Which is an example of a column that would contain statistics necessary for programming?

Answer

Correct Answer: CARDF

Note: This Question is unanswered, help us to find answer for this one

48. Why must the DB2 precompiler be used to execute SQL statements?

Answer

Correct Answer: The compiler does not recognize SQL statements.

Note: This Question is unanswered, help us to find answer for this one

49. What four languages can host variable arrays be specified in?

Answer

Correct Answer: C, C++, COBOL, or PL/I.

Note: This Question is unanswered, help us to find answer for this one

50. Can the SQL procedural language be used for advanced functions?

Answer

Correct Answer: No.

Note: This Question is unanswered, help us to find answer for this one

51. What is the Java data access platform used in DB2?

Answer

Correct Answer: pureQuery.

Note: This Question is unanswered, help us to find answer for this one

52. What happens when the execution of a utility is terminated by the TERM command?

Answer

Correct Answer: The execution ends normally, the corresponding row in the SYSUTIL table is removed, all resources are freed.

Note: This Question is unanswered, help us to find answer for this one

53. Which of the following is not a DB2 object

Answer

Correct Answer: Column

Note: This Question is unanswered, help us to find answer for this one

54. In what catalog table must stored procedures be defined?

Answer

Correct Answer: SYSPROCEDURES

Note: This Question is unanswered, help us to find answer for this one

55. Which of the following is a correct syntactical example of written SQL code?

Answer

Correct Answer: EXEC SQL SELECT TYPE INTO :book_type FROM BOOK_TYPES WHERE

Note: This Question is unanswered, help us to find answer for this one

56. What is an example of an underlying cause for regressions caused by changes in DB2?

Answer

Correct Answer: Inadequate statistics.

Note: This Question is unanswered, help us to find answer for this one

57. When should we execute a REBIND rather than a BIND

Answer

Correct Answer: C & E

Note: This Question is unanswered, help us to find answer for this one

58. SQLSTATE is a standard set of error messages and warnings in which the first two characters defines the class and the last three defines the subclass of the error. Which of the following SQLSTATE codes is interpreted as "No data returned"?

Answer

Correct Answer: 02xxx

Note: This Question is unanswered, help us to find answer for this one

59. Given the following DDL statements: CREATE TABLE Smart1 (a INT, b INT, c INT) CREATE VIEW View1 AS SELECT a,b,c FROM Smart1 WHERE a > 250 WITH CHECK OPTION Which of the following INSERT is correct

Answer

Correct Answer: INSERT INTO View1 VALUES (300, 2, 3)

Note: This Question is unanswered, help us to find answer for this one

60. Which of the following is correct SQLJ syntax?

Answer

Correct Answer: #sql [myConnCtxt] { UPDATE EMP

Note: This Question is unanswered, help us to find answer for this one

61. What happens to SQL statements if there are no stored procedures?

Answer

Correct Answer: They are embedded.

Note: This Question is unanswered, help us to find answer for this one

62. What code is used to start the CICS attachment facility?

Answer

Correct Answer: EXEC CICS LINK PROGRAM('DSNyCOM ')

Note: This Question is unanswered, help us to find answer for this one

63. What must happen before using the EXPLAIN statement?

Answer

Correct Answer: A plan table must be created to hold the results of EXPLAIN.

Note: This Question is unanswered, help us to find answer for this one

64. Which of the following is a DB2 mechanism that ensures data integrity between tables related by Primary & Foreign Keys

Answer

Correct Answer: Referential integrity

Note: This Question is unanswered, help us to find answer for this one

65. When are dynamic SQL applications prepared?

Answer

Correct Answer: While the program is running.

Note: This Question is unanswered, help us to find answer for this one

66. What would the “SQL CONNECT” statement be used for when coding stored procedures?

Answer

Correct Answer: It allows an application to communicate with DB2.

Note: This Question is unanswered, help us to find answer for this one

67. Given the following DDL statement: CREATE TABLE newsmart1 LIKE smart1 Which of the following would occur as a result of the statement execution?

Answer

Correct Answer: newsmart1 columns have same attributes as smart1

Note: This Question is unanswered, help us to find answer for this one

68. Which of the following is an example of a programming method not used in DB2 programming?

Answer

Correct Answer: Hadoop

Note: This Question is unanswered, help us to find answer for this one

69. Which of the following occurs if a DB2 procedure or application ends abnormally during an active unit of work?

Answer

Correct Answer: The unit of work is rolled back

Note: This Question is unanswered, help us to find answer for this one

70. What type of SQL operator would you use to combine the results of 2 Select statements while retaining the duplicates

Answer

Correct Answer: Union All

Note: This Question is unanswered, help us to find answer for this one

71. A declared temporary table is used for which of the following purposes?

Answer

Correct Answer: To store intermediate results

Note: This Question is unanswered, help us to find answer for this one

72. A role is a database entity that groups together one or more privileges. Which of the following is true for a "role"

Answer

Correct Answer: All of the above

Note: This Question is unanswered, help us to find answer for this one

73. Which of the following statements eliminates all but one of each set of repeated rows inthe final result table?

Answer

Correct Answer: SELECT DISTINCT * FROM t1

Note: This Question is unanswered, help us to find answer for this one

74. What is a stored procedure?

Answer

Correct Answer: A program to execute SQL statements.

Note: This Question is unanswered, help us to find answer for this one

75. What is a host structure?

Answer

Correct Answer: A group of host variables that an SQL statement can refer to by using a single name.

Note: This Question is unanswered, help us to find answer for this one

76. What is SQLCA used for?

Answer

Correct Answer: It checks the execution of SQL statements.

Note: This Question is unanswered, help us to find answer for this one

77. What are three examples of languages you can use to program in DB2?

Answer

Correct Answer: COBOL, Fortran, and Perl.

Note: This Question is unanswered, help us to find answer for this one

78. Which of the following is the correct syntax for an input variable of a PARMLIST string?

Answer

Correct Answer: DCL SINTVAR BIN FIXED(15);

Note: This Question is unanswered, help us to find answer for this one

79. What technique can DB2 use to more effectively interpret data from EXPLAIN tables?

Answer

Correct Answer: Parallel processing.

Note: This Question is unanswered, help us to find answer for this one

80. What are the three primary development environments for DB2?

Answer

Correct Answer: WebSphere Studio, Microsoft Visual Studio, and IBM Optim Development Studio.

Note: This Question is unanswered, help us to find answer for this one

81. Which of the following is not one of the types of authorizations associated with a DB2 user?

Answer

Correct Answer: SQL Authorization ID

Note: This Question is unanswered, help us to find answer for this one

82. How does one prepare a Java program that contains JDBC methods?

Answer

Correct Answer: Use the “javac” command.

Note: This Question is unanswered, help us to find answer for this one

83. What must a SELECT statement be coded within?

Answer

Correct Answer: A DECLARE CURSOR.

Note: This Question is unanswered, help us to find answer for this one

84. What's the output of a DB2 Bind

Answer

Correct Answer: DB2 Application plan

Note: This Question is unanswered, help us to find answer for this one

85. What are two examples of steps that must be taken before coding an application with embedded static or dynamic SQL statements?

Answer

Correct Answer: Precompile, and bind.

Note: This Question is unanswered, help us to find answer for this one

86. Before executing SQL statements, you want to know whether the CICS attachment facility is available. How do you check?

Answer

Correct Answer: Use the EXTRACT EXIT command in your application, or INQUIRE EXITPROGRAM in version 4.0.

Note: This Question is unanswered, help us to find answer for this one

87. Why would you receive a command response of NORMAL when the attachment facility is not available?

Answer

Correct Answer: The exit was not ENABLE STARTED.

Note: This Question is unanswered, help us to find answer for this one

88. Which statement about an index is NOT true?

Answer

Correct Answer: The name of an index can be mentioned in a Select statement, to improve the performance of the query.

Note: This Question is unanswered, help us to find answer for this one

89. What is a lightweight web application created from multiple sources?

Answer

Correct Answer: A mashup.

Note: This Question is unanswered, help us to find answer for this one

90. Which of the following can be accomplished with a single UPDATE statement?

Answer

Correct Answer: Updating a table based on a sub-select using joined tables

Note: This Question is unanswered, help us to find answer for this one

91. When coding in a language that requires a host variable declaration, what must precede it?

Answer

Correct Answer: ;hostvar

Note: This Question is unanswered, help us to find answer for this one

92. What is the name of the effect when a system continues to receive work, but is down?

Answer

Correct Answer: Stormdrain effect.

Note: This Question is unanswered, help us to find answer for this one

93. Consider the following: DECLARE MYCURS CURSOR FOR SELECT * FROM MYTABLE WHERE COL1 > :NUM Which of the following embedded SQL statements will NOT generate an error?

Answer

Correct Answer: FETCH MYCURS INTO :HOSTMYTABLE:IND

Note: This Question is unanswered, help us to find answer for this one

94. What is a benefit of concurrency in SQL application programming?

Answer

Correct Answer: Minimization of data access conflicts.

Note: This Question is unanswered, help us to find answer for this one

95. What is an example of a benefit of using the Java programming language?

Answer

Correct Answer: Once you develop an application, it can be run anywhere.

Note: This Question is unanswered, help us to find answer for this one

96. What must be done to a DB2 application before it can run, and why?

Answer

Correct Answer: It has to be binded first so it can recognize SQL statements.

Note: This Question is unanswered, help us to find answer for this one

97. How are ODBC calls binded?

Answer

Correct Answer: They are not binded because they use standard functions to execute SQL.

Note: This Question is unanswered, help us to find answer for this one

98. SQL statements embedded into an application is called what?

Answer

Correct Answer: Static SQL.

Note: This Question is unanswered, help us to find answer for this one

99. Can static SQL statements be changed without altering the program itself?

Answer

Correct Answer: No.

Note: This Question is unanswered, help us to find answer for this one

100. When is it necessary to precompile DB2 REXX procedures before running them?

Answer

Correct Answer: Never because they use dynamic SQL.

Note: This Question is unanswered, help us to find answer for this one

101. Given the statement: CREATE TABLE t1 (c1 INTEGER NOT NULL,c2 INTEGER,PRIMARY KEY(c1),FOREIGN KEY(c2) REFERENCES t2) How many non-unique indexes are defined for table t1?

Answer

Correct Answer: 0

Note: This Question is unanswered, help us to find answer for this one

102. When a user has a SELECT authorization on a certain base table, and he creates a view on that table alone, then which of the following is true?

Answer

Correct Answer: He/She only has a SELECT authorization on that view.

Note: This Question is unanswered, help us to find answer for this one

103. When declaring a foreign key on a table, referencing an existing primary key with complete definition, what might differ between foreign key and primary key?

Answer

Correct Answer: The nullability of one of the included columns.

Note: This Question is unanswered, help us to find answer for this one

104. Which of the following is true about the EXPLAIN command

Answer

Correct Answer: C,D & E

Note: This Question is unanswered, help us to find answer for this one

105. Consider the following SQL statement, executed by user S001: CREATE VIEW BOSTON_TEAMS AS SELECT * FROM TEAMS WHERE STATE = 'MA' User S002 has INSERT authority on this view, what would happen if he tries to insert a row into this view, where the STATE field of that line contains a value of ‘IN’?

Answer

Correct Answer: The row will be inserted in the table S001.TEAMS, but it will never show up in a SELECT on this view.

Note: This Question is unanswered, help us to find answer for this one

106. Given the following cursor declaration: DECLARE CLASSUPDATE CURSOR FOR SELECT CSTITLE FROM T001.CLASSS FOR UPDATE OF CDUR Which of the following embedded SQL statements will use this cursor correctly?

Answer

Correct Answer: UPDATE T001.CLASSS SET CDUR = 5 WHERE CURRENT OF CLASSUPDATE

Note: This Question is unanswered, help us to find answer for this one

107. When a column has an extension of WITH DEFAULT NULL and a unique index is created on this column, what will be the effects on the possible null values in that column?

Answer

Correct Answer: There is still a single null allowed, since it is unique as such.

Note: This Question is unanswered, help us to find answer for this one

108. Which of the following is not a DB2 datatype

Answer

Correct Answer: Long Graphic

Note: This Question is unanswered, help us to find answer for this one

109. Which of the following statements concerning locking on TABLESPACE level is correct?

Answer

Correct Answer: When a TABLESPACE is S-locked by another user, a U-lock can be placed. However, an X-lock is not compatible and will have to wait until the S-lock is released.

Note: This Question is unanswered, help us to find answer for this one

110. SELECT empname , paygrade , salary FROM emp, salgrade WHERE salary BETWEEN lowsal AND highsal ORDER BY paygrade The above is an example of a

Answer

Correct Answer: Non equi join

Note: This Question is unanswered, help us to find answer for this one

111. Which subquery operator compares a single value to every member of set of value.

Answer

Correct Answer: Any

Note: This Question is unanswered, help us to find answer for this one

112. Which statement about tablespaces is true?

Answer

Correct Answer: Dropping a tablespace will not only remove all tables of the tablespace itself, but also all indexes created on these tables, even tho ugh they are stored separately in their own indexspace.

Note: This Question is unanswered, help us to find answer for this one

113. When you don't know the format of an SQL statement within a program you're writing, what is a good option?

Answer

Correct Answer: Dynamic SQL.

Note: This Question is unanswered, help us to find answer for this one

114. Which of the following is true about locking

Answer

Correct Answer: All of the above

Note: This Question is unanswered, help us to find answer for this one