1 DB 2

You might also like

You are on page 1of 14

1. Which of the following statement is correct?

Stored Procedure can have SQL and Host Language statements.


Stored Procedure can have SQL statements only.
Stored Procedure can have Host Language statements only.
none of the above
2. Which of the following statement cannot have in Stored procedure?
COMMIT
SET CURRENT SQL ID
COMMIT and SET CURRENT SQL ID
None of the above
3. Which of the following statement is correct?
Stored procedure cannot access tables at other DB2 locations
Stored procedure can access tables at other Db2 locations using Connect Statement alone
Stored procedure can access tables at other DB2 locations using 3 part object names
alone
Stored procedure can access tables at other DB2 locations using Connect statement or 3
part object names or private protocols

Stored procedures can access tables at other DB2 locations using 3-part object names or
CONNECT statements.
If you use CONNECT statements, you use DRDA access to access tables. If you use 3-part
object names or aliases
for 3-part object names, the distributed access method depends on the value of
DBPROTOCOL you specified when you bound
the stored procedure package. If you did not specify the DBPROTOCOL bind parameter,
the distributed access method depends on the value of field DATABASE PROTOCOL on
installation panel DSNTIP5.
A value of PRIVATE tells DB2 to use DB2 private protocol access to access remote data for
the stored procedure.
DRDA tells DB2 to use DRDA access.

4. In the Stored Procedure Connect statement uses ______________.


DRDA access to access tables
Value specified in DBPROTOCOL when stored procedure Package is bound.
Value in Database Protocol on installation Panel
None of the above
5. Which of the following is not true as far as external procedure is concerned?

Store procedure Definition Specifies the name of the stored procedure program.
Define the stored procedure to DB2 by preprocessing a CREATE PROCEDURE statement,
then executing the CREATE PROCEDURE statement statically or dynamically
Define stored procedure to DB2 by executing the CREATE PROCEDURE statement.
none of the above

An external stored procedure and an SQL procedure differ in the way that they specify the
code for the stored procedure.
An external stored procedure definition specifies the name of the stored procedure
program.
An SQL procedure definition contains the source code for the stored procedure.
For an external stored procedure, you define the stored procedure to DB2 by executing
the CREATE PROCEDURE statement.
You change the definition of the stored procedure by executing the ALTER PROCEDURE
statement.
For an SQL procedure, you define the stored procedure to DB2 by preprocessing a
CREATE PROCEDURE statement,
then executing the CREATE PROCEDURE statement statically or dynamically. As with an
external stored procedure,
you change the definition by executing the ALTER PROCEDURE statement but
cannot change the procedure body with the ALTER PROCEDURE statement.

6. Creating SQL procedure involves defining SQL procedure to DB2


TRUE
FALSE

Creating an SQL procedure involves writing the source statements for the SQL procedure,
creating the executable form of the SQL procedure, and defining the SQL procedure to
DB2.

7. Which of the following statement is true?


Handlers can be used in SQL procedures
There is no such concept of handlers in SQL procedures
Handlers can be declared but they cannot be tailored to specific SQL STATE
Usage of handlers will decrease the performance

8. Which of the following should be taken into consideration while coding an SQL?
1. Use of ORDER BY GROUP BY Clause
2. Fetching unused rows and columns
3. Minimizing Lock duration
4. Redundant Predicates
a) 2 & 3 alone
b) 1 & 4 alone
c) 2, 3, & 4 alone
d) all of the above
9. Aggregate functions performs best ____________.
1. When evaluated after data has been accessed
2. When evaluated during data access
3. When evaluated during DB2 sort
Order of performance (Best first) should be ?
a) 1, 2, 3
b) 2, 3, 1
c) 1, 3, 2
d) 3, 2, 1

If a query involves aggregate functions, make sure that they are coded as simply as
possible, this increases the chances that they will be evaluated when the data is retrieved,
rather than afterward. In general, a aggregate function performs best when evaluated
during data access and next best when evaluated during DB2 sort. Least preferable is to
have an aggregate function evaluated after the data has been retrieved.
10. How many JOIN conditions are needed in JOIN query to avoid a cartesian product?
No of tables + 1
No of columns – 1
No of columns + 1
No of tables – 1
11. Which of the following SQL source code are stored in system catalog?
Views
Tables
Triggers
Constraints

Ans: Triggers -- need to check

12. What determines when checkpoints are taken for DB2 subsystem restart?
ARCHIVE LOG FREQ
LOGLOAD
UPDATE RATE
CHECKPOINT FREQ

13. What does HOLE occur in the result table?


Deleting or updating rows after a static cursor is open can result in holes in the result
table.
Deleting or updating rows after a dynamic cursor is open can result in holes in the result
table.
Deleting rows after a dynamic cursor is open can result in holes in the result table.
All of the above

14. Which of the following statement is true while selecting access path?
1. Predicates in the having clause is not used
2. Predicates in the Where clause alone is used
3. Predicates in the On Clause alone is used
a) 1 and 2
b) 1 and 3
c) 2 and 3
all of the above

Predicates in a HAVING clause are not used when selecting access paths. hence, the term
'predicate‘ means a predicate after WHERE or ON.

15. Index only access is __________.


ACCESSTYPE =R AND INDEXONLY = Y
ACCESSTYPE =1 AND INDEXONLY = N
ACCESSTYPE=1 AND INDEXONLY = Y
ACCESSTYPE=R AND INDEXONLY = N
Indexonly access is When required data can be taken from index pages and no need to
access data page Much efficient ACCESSTYPE = I AND INDEXONLY = Y

16. Merge Scan Join is more efficient when __________.


filtering for both the tables (outer and inner) are high
highly clustered index is available on join columns of the inner table
the tables (inner and outer) are large and does not provide much filtering
all of the above
Merge scan is used when Qualifying rows of inner and outer tables are large and join
predicates also does not provide much filtering Tables are large and have no indexes with
matching columns

Nested loop join is efficient when Outer table is small


The number of data pages accessed in inner table is also small.
Highly clustered index available on join columns of the inner table.
This join method is efficient when filtering for both the tables(Outer and inner) is high.

Hybrid join is used often when a non-clustered index available on join column of the
inner table and there are duplicate qualifying rows on outer table.
Hybrid join handles are duplicates in the outer table as inner table is
scanned only once for each set of duplicate values.

17. Which of the following options will help release locks more quickly and contribute
to maximum concurrency?

Lock size of one page


Cursor stability
Repeatable read
Both a and b

18. What is the purpose of the SQL Communications Area?

It provides SQL with an area to put error codes.


It provides an area for passing parameters back and forth between your program and
SQL.
It provides an area for DB2 to pick up the SQL statements in your program.
It provides an area for passing input between your terminal and SQL

19. In Db2, plans are stored in

SYSIBM.SYSPLAN
SYSIBM.PLANTABLE
SYSIBM.PLAN
SYSIBM.COPY

20. SQLCA is used as a


Communication area between DB2 and application program
Communication area between the system and DB2 DBRM
Change area / Stack area to store the intermediate data from DB2
TO store data from retrieved DB2 rows of a table

21. During pre-compilation process,DB2 does the following


Checks for DB2 syntax
Produces the dataset containing SQL statements
Produces modified source code with EXEC SQL replaced by CALLS to DB2 processor.
All of the above
22. Which of the following SQL data types should be used to store double byte
character data?
CLOB
CHAR
VARCHAR
GRAPHIC

23. If a fetch encounters an update or delete hole, what is the SQLCODE returned to
the program?
+100
+222
+212
+112

24. SQL needs COBOL/PL1's help to do ONE of the tasks listed below.
From what you know of SQL, which task do you think is best done by embedding SQL in
a COBOL/PL1 program?
Create a table
Produce a one-time listing of all rows from one or more tables
Update a table based on values contained in a transaction file
Grant another user authority to access a table you created

25. When language environment need to be refreshed for stored procedures?


Load module is purged from the address space and reloaded when invoked again
Load module is over written
Load module is left undisturbed
None of the above

Ans: Load module is purged from the address space and reloaded when invoked again
(doubt)

Refreshing the stored procedures environment


Depending on what has changed in a stored procedures environment, you might need to
perform one or more of these tasks:
Refresh Language Environment.
Do this when someone has modified a load module for a stored procedure, and that load
module is cached in a stored procedures address space. When you refresh Language
Environment, the cached load module is purged. On the next invocation of the stored
procedure, the new load module is loaded.

26. Creating SQL procedure involves ___________.


Writing Source SQL statement
Creating SQL form of stored procedure
Defining SQL procedure to DB2
all of the above

Creating an SQL procedure involves writing the source statements for the SQL
procedure, creating the executable form of the SQL procedure, and defining the SQL
procedure to DB2.

27. How many TCB can have in each Stored Procedures address space?
One
More than one TCB
two only
three only

28. In the Stored Procedure 3-part object names uses _________________.

1. DRDA access to access tables


2. Value specified in DBPROTOCOL when stored procedure Package is bound.
3. Value in Database Protocol on installation Panel
a) 1 alone
b) 2 or 3
c) 2 alone
d) all

If you use 3-part object names or aliases for 3-part object names, the distributed access
method
depends on the value of DBPROTOCOL you specified when you bound the stored
procedure package.
If you did not specify the DBPROTOCOL bind parameter, the distributed access method
depends on the
value of field DATABASE PROTOCOL on installation panel DSNTIP5.

29. If the stored procedure runs in WLM established address space, your AMODE can
be ______.

24 bits
24 or 31 bits
31 bits
Any

30. Which of the following statement is correct?


Stored Procedure can be coded as re-entrant and re-usable program.
Stored Procedure can be coded as re-usable program but not as re-entrant program.
Stored Procedure cannot be coded as re-entrant.
Stored Procedure can be coded as re-entrant and but not as re-usable program.

Ans:To prepare a stored procedure as reentrant, compile it as reentrant and link-edit it as


reentrant and reusable.

31. Which of the following statement regarding Encryption is correct?


Degrades the performance of the SQL
Requires extra processing time
Both a and b
none of the above

32. Which of the following statement regarding predicate is true for better
performance?
1. Predicates should be on either leading or all index key columns
2. At least one predicates should be in the list of indexed columns
3. Predicates need not be indexed
a) 1 and 2
b) 1 and 3
c) 2 and 3
d) all of the above

33. DB2 performs correlated subquery


TRUE
FALSE

34. What is a Hybrid Join?


Ans: Hybrid join is one of the methods that DB2 uses to join tables. This method has two
phases. During phase 1, DB2 scans the outer table and joins it with a suitable inner table
index based on the join columns. If the outer table does not have an index to provide the
join order, the outer table is sorted in the order of the join columns.

35. Local Predicate is


Ans: Local predicates reference only one table. They are local to the table and restrict the
number of rows returned for that table. Join predicates involve more than one table or
correlated reference. They determine the way rows are joined from two or more tables.

36. How does DB2 determine what lock size to use?


Ans: LOCKSIZE is defined with the CREATE TABLESPACE DDL.

37. Command to move a File pointer to a particular record in Vsam.


Ans: STARTBR

38. Represent a null dataset in JCL


Ans: DD DUMMY
39. What are the sub parameters in DCB?
Ans: LRECL, BLKSIZE, BUFNO, RECFM, KEYLEN, DSORG, OPTCD
40. When is the region parameter not specified in the Job?
Ans: If no REGION parameter is specified, the system uses an installation default
specified at JES initialization.
Default is 512K

41. What is TCB?


Ans: Originally CICS executed under a single operating system Task Control Block (TCB).

42. Stored Procedure running in WLM established address space can have __________.
Explicit CAF
Implicit CAF calls
RRSAF calls implicitly
RRSAF calls explicitly

43. Which of the following order is correct?


In the Stored Procedure, Order of statement in Compound Statement
1. SQL variable and condition Declaration
2. Cursor Declaration
3. Handler Declaration
4. Procedure body statements
a) 2,3,1,4
b) 2,1,4,3
c) 1,2,3,4
d) 1,3,2,4

44. Which of the following statement regarding EXPLAIN is correct?


1. Gives information about Plan, Package
2. Design Database and indexes
3. Information about the access path chosen for the query
a) 1 and 2
b) 1 and 3
c) 2 and 3
all of the above

45. Which of the following regarding Table spaces scan is correct?


1. Used when more number of rows are returned
2. Used when no indexes are available
3. Used when indexes are available and they have low cluster ratio
a) 1 and 2
b) 1 and 3
c) 2 and 3
all of the above

46. If more than one index is used, DB2 ______________.


Will choose one with least filter factor
Will choose one with best filter factor
Will not consider the filter factor itself
Does not have any concept called filter factor
47. What does mean One Fetch access?
When a query returns needed row in one step of page access

When a query returns needed row in one step of data page access
When a query returns needed row in one step of index page access
none of the above

ONE FETCH - When a query returns needed row in one step of page access
Only one table in the query MIN or MAX column functions No GROUP BY

48. What field in the SQLCA can you check to determine if your SQL statement
executed successfully?
SQLCODE field
SQLSTATE field
Both a and b
None of the above

49. WLM is ___________


Component of OS/390
Manages the transaction through the use of dynamic transaction routing.
Manages number of address spaces in each environment
All of the above
WLM (Work Load Manager) is a component of OS/390. It is responsible for managing the
transaction workload through the use of dynamic transaction routing. WLM can manage
a number of address spaces for each environment.

50. Stored Procedures are stored in


SYSIBM.SYSROUTINES

51. What is the most convenient way to get a DECLARE TABLE statement into your
program?
INCLUDE a member created by DCLGEN
Simply code it yourself Use a text editor to copy an existing DECLARE TABLE statement
into your program.
none of the above

52. Handlers are used only when there is ______________.


When there is SQL error
When there is SQL warning
When more than one row are returned
All of the above

53. If the stored procedure runs in WLM established address space, you should use.
DSNALI
DSNRLI
Both a and b
none of the above

DSNALI -The language interface module for the call attachment facility. Link-edit or load
this module if your stored procedure runs in a DB2-established address space.

DSNRLI - The language interface module for the Recoverable Resource Manager Services
attachment facility.
Link-edit or load this module if your stored procedure runs in a WLM-established address
space.
If the stored procedure references LOBs or distinct types, you must link-edit or load
DSNRLI.

54. Which of the following statement regarding Materialized Query tables is correct?

Used to store the results of query in advance in the case of dynamic queries
DB2 may not use the materialized query tables if they do not have any performance
advantage
They need special registers to be used by DB2
All of the above

Dynamic queries that operate on very large amounts of data and involve multiple joins
might take a long time to run.
One way to improve the performance of these queries is to generate the results of all or
parts of the queries in advance, and store the results in materialized query tables.

55. Column Correlation is _______________.


Two columns in a table vary independently
Two columns in a table do not vary independently
Both a and b
none of the above

56. Does a query have a problem with column correlation?


Two columns in a table are said to be correlated if the values in the columns do not
vary independently. DB2 might not determine the best access path when your
queries include correlated columns

57. Stored procedure can call Other _________________.


host language subprogram
host language subprogram and stored procedures
host language subprogram, stored procedures and User defined functions.
host language subprogram and User defined functions.

58. Stored procedures address spaces can be established by ____________.


DB2 alone
WLM alone
Both a and b
none of the above

59. Which of the following is not a valid Cursor positioning technique in CICS
Static Cursor Positioning
Symbolic Positioning
Standard Positioning
Relative Positioning

60. Once a HANDLE CONDITION command is issued for a specific condition, how long
does it remain in effect?
Until another HANDLE CONDITION executes for the same condition
Until an IGNORE CONDITION command executes for the same condition
Until the program terminates
All of the above

61. Which of the following statement is correct?


WLM can start a stored procedure
WLM can stop a stored procedure
Both a and b
none of the above

62. When we use stored procedure as sub programs?


a)i/o cant be perfomed
b)stop/exit in pli,stiop run in cobol
c)all of the above
When you code stored procedures as subprograms, follow these rules:
For example, you cannot perform I/O operations in a PL/I subprogram.
Avoid using statements that terminate the Language Environment enclave when the
program ends.
Examples of such statements are STOP or EXIT in a PL/I subprogram, or STOP RUN in a
COBOL subprogram.
If the enclave terminates when a stored procedure ends, and the client program calls
another stored procedure that runs as a subprogram, then Language Environment
must build a new enclave. As a result, the benefits of coding a stored procedure as a
subprogram are lost.

63. How you can read a file from bottom?


a) 1. QSAM (sequential) file. You can run it thru SORT utility adding SEQNUM and then
sort then sort by SEQNUM in DESC order
b) VSAM: In CICS, you can read backward using READREV
c) VSAM: I Batch, unload the VSAM file using SORT in DESC order by key value
d) All of the above*****.

64. How often should you check the SQLCA?


a) After almost every SQL statement is executed
b) Each time SQL updates a table
c) At the end of the job
d) Each time SQL needs a table

What is the best reason for providing extra WHERE clause conditions when you
are joining tables?
a) Better documentation
b) The more qualified your condition, the safer it is
c) To enable DB2 to decide on the best way to access the data
d) all of the above

List sequential prefetch reads ________________.


a) Set of data pages determined by list of RIDs
b) Set of pages
c) Set of Index pages
d) none of the above

Which of the following statement is correct?


a) Stored Procedure can have SQL and Host Language statements.
b) Stored Procedure can have SQL statements only.
c) Stored Procedure can have Host Language statements only.
d) none of the above

How many JOIN conditions are needed in JOIN query to avoid a cartesian
product?
a) No of tables + 1
b) No of tables - 1
c) No of columns + 1
d) No of columns 1

Stored Procedure running in WLM established address space can have __________.
a) Explicit CAF
b) Implicit CAF calls
c) RRSAF calls implicitly
d) RRSAF calls explicitly

How often should you check the SQLCA?


a) After almost every SQL statement is executed
b) Each time SQL updates a table
c) At the end of the job
d) Each time SQL needs a table

Which of the following should be taken into consideration while coding an SQL?
1. Use of ORDER BY GROUP BY Clause
2. Fetching un used rows and columns
3. Minimizing Lock duration
4. Redundant Predicates
a) a) 2 & 3 alone
b) b) 1 & 4 alone
c) c) 2, 3, & 4 alone
d) d) all of the above

Which of the following statement is correct?


1. Indexes cannot be created on encrypted data
2. Range checking of Encrypted data occupies more spaces
3. Indexes can be created on encrypted data
a) a) 1 & 2
b) b) 2 & 3
c) c) 1 & 3
d) none of the above

DSNALI is a ___________.
a) Language interface module for call attachment facility
b) Language interface module for recoverable resource manager services
attachment facility
c) Both a and b
d) none of the above

Which of the following statement is correct?


a) Stored procedure cannot access tables at other DB2 locations
b) Stored procedure can access tables at other Db2 locations using Connect
Statement alone
c) Stored procedure can access tables at other DB2 locations using 3 part object
names alone
d) Stored procedure can access tables at other DB2 locations using Connect
statement or 3 part object names or private protocols

materialized query tables are________________?

a) USER created and SYSTEM maintained tables.


b) SYSTEM created and maintained tables.
c) USER created and SYSTEM/USER Maintained tables.
d) All of the above.
Which of the following is valid use of host variable?
a) As the source of the column value.
b) As the target of the column value.
c) As a variable in a WHERE clause.
d) All of the above
Which of the following regarding table space scan is correct?
a) Used when more no of rows are returned.
b) Used when no indexes are available
c) Used when indexes are available and they have low cluster ratio.
1&2
1&3
2&3
All of the above
Sequential pre fetch is generally used for?
a) For table space scan
b) For index space scan
c) Both A and B
d) All of the above
What is the CICS command that gives the length of TWA?
a) LENGTH
b) SIZE
c) ASSIGN
d) VALUE
Ans: TWALENG

Which data structures uses FIFO technique where the first element added to the data
structure is the first removed
a) QUEUE
b) STACK
c) BOTH
d) None of these
In REXX comment starts with?
a) /*REXX
b) // REXX
c) //* REXX
d) None
Which instruction stops execution from within the loop and passes control to the DO
instruction at the top of the loop.
a) Leave
b) Nop
c) Exit
d) Iterate
Which instruction causes an exec to unconditionally end and return to where the exec
was invoked
a) LEAVE
b) EXIT
c) BOTH
d) None

if you execute stored procedure locally

output fields needs to be initialised


not required
there is no need of output field
none

acquire(all)
meterialized query

not required when there is no perfomance advantage with meterialized query

You might also like