Latest DB2 Programming Questions
Which of the following is true about locking
A. All of the above
B. Locking prevents concurrent users from accessing inconsistent data.
C. Locking is a process that is used to ensure data integrity.
D. The data (row) is locked until a commit is executed to release the updated data.
Ans: A
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?
A. He/She can only execute an UPDATE as long as the definition of the view is not exceeded.
B. He/She also has DELETE authorization on that view because he/she is the creator of the view.
C. He/She will face an authorization error when trying to create the view
D. He/She only has a SELECT authorization on that view.
Ans: D
What is a lightweight web application created from multiple sources?
A. A smashup.
B. A mashup.
C. A crackup.
D. A mixup.
Ans: B
A role is a database entity that groups together one or more privileges. Which of the following is true for a “role”
A. A role cannot be a primary authorization ID.
B. A role cannot be set by using a SET CURRENT SQLID statement.
C. All of the above
D. A role can be the schema qualifier of an object. However, when it is used as a schema qualifier, a role is considered to be a character string and does not add any implicit schema privileges (ALTERIN, CREATEIN, or DROPIN) to this role.
Ans: C
What are the three primary development environments for DB2?
A. PhotoData Studio, Microsoft Visual Studio, and IBM Optim Development Studio.
B. WebSphere Studio, Adobe Acrobat Studio, and IBM Optim Development Studio.
C. Silverlight Studio, Microsoft Visual Studio, and IBM Optim Development Studio.
D. WebSphere Studio, Microsoft Visual Studio, and IBM Optim Development Studio.
Ans: D
What is a stored procedure?
A. An SQL statement.
B. An SQL statement to execute a program.
C. A method for using wrappers to encode SQL.
D. A program to execute SQL statements.
Ans: D
What would the “SQL CONNECT” statement be used for when coding stored procedures?
A. It connects DB2 with Java.
B. It connects DB2 with the database.
C. It allows an application to communicate with DB2.
D. It connects DB2 with Active Directory.
Ans: C
Which of the following is a DB2 mechanism that ensures data integrity between tables related by Primary & Foreign Keys
A. Referential integrity
B. Data Integrity
C. Pre-compilation
D. B & C
Ans: A
When are dynamic SQL applications prepared?
A. When the program is not running.
B. While the program is running.
C. When the system is turned off.
D. When the program is sandboxed.
Ans: B
Given the following DDL statement: CREATE TABLE newsmart1 LIKE smart1 Which of the following would occur as a result of the statement execution?
A. newsmart1 has same triggers as smart1
B. newsmart1 has the same primary key as smart1
C. newsmart1 columns have same attributes as smart1
D. newsmart1 is populated with smart1 data
Ans: C
Which of the following occurs if a DB2 procedure or application ends abnormally during an active unit of work?
A. The unit of work moves to CHECK_PENDING
B. The unit of work is rolled back
C. The unit of wok moves to pending state
D. The unit of work remains active
Ans: B
What must happen before using the EXPLAIN statement?
A. A stored procedure must be made to process it.
B. A Java wrapper must be written to use it.
C. A planned procedure must be made to execute it.
D. A plan table must be created to hold the results of EXPLAIN.
Ans: D
What code is used to start the CICS attachment facility?
A. CICSgo
B. CICSstart
C. EXEC CICS LINK PROGRAM(‘DSNyCOM ‘)
D. CICS
Ans: C
A declared temporary table is used for which of the following purposes?
A. To provide an area for database manager sorts
B. To create a backup copy of a database or table space
C. To share result sets between applications
D. To store intermediate results
Ans: D
Which of the following is an example of a programming method not used in DB2 programming?
A. Hadoop
B. OBDC
C. Dynamic SQL.
D. Static SQL
Ans: A
Which of the following statements eliminates all but one of each set of repeated rows inthe final result table?
A. SELECT * FROM DISTINCT T1
B. SELECT DISTINCT * FROM t1
C. SELECT UNIQUE * FROM t1
D. SELECT UNIQUE (*) FROM t1
Ans: B
What is a host structure?
A. A variable group of hosts that an SQL statement can refer to by using any name.
B. A group of host variables that an SQL statement can refer to by using a single name.
C. A group of host variables that an SQL statement can process.
D. A single host variable that an SQL statement can refer to by using a single name.
Ans: B
Which of the following DB2 objects allows multiple users to access data in a table with each only being able to access certain subsets of the data?
A. Views
B. Aliases
C. Indexes
D. Mirrored Tables
Ans:A
What type of SQL operator would you use to combine the results of 2 Select statements while retaining the duplicates
A. Union All
B. Intersect
C. Union
D. Inner Join
Ans: A
What is SQLCA used for?
A. It checks the code of SQL statements.
B. It checks the locking of SQL statements.
C. It checks the execution of SQL statements.
D. It parses stored procedures.
Ans:C
What are three examples of languages you can use to program in DB2?
A. Perl, Python, and PL/SQL.
B. COBOL, Fortran, and Perl.
C. HTML, MSDOS, Python.
D. PHP, Ruby on Rails, and Haskell.
Ans:B
What technique can DB2 use to more effectively interpret data from EXPLAIN tables?
A. Quadratic processing.
B. Networked processing.
C. Unilateral processing.
D. Parallel processing.
Ans:D
When coding in a language that requires a host variable declaration, what must precede it?
A. ;hostchar
B. ;iostream.h
C. ;hostvar
D. ;varchar
Ans:C
Which of the following is the correct syntax for an input variable of a PARMLIST string?
A. DCL SINTAR BIN FAXED(15);
B. DCL SINvTAR BIN FIXED(15);
C. (15)DCL SINTVAR BIN FIXED;
D. DCL SINTVAR BIN FIXED(15);
Ans:D
Before executing SQL statements, you want to know whether the CICS attachment facility is available. How do you check?
A. You shut down DB2 and check in the CICS kernal.
B. You check in the CICS configuration file.
C. You check in the CICS configuration menu.
D. Use the EXTRACT EXIT command in your application, or INQUIRE EXITPROGRAM in version 4.0.
Ans:D
What are two examples of steps that must be taken before coding an application with embedded static or dynamic SQL statements?
A. Pretranscribe, and bind.
B. Transcribe, and bind.
C. Compile, and bind.
D. Precompile, and bind.
Ans:D
Why would you receive a command response of NORMAL when the attachment facility is not available?
A. The exit was disabled.
B. The exit was not enabled.
C. The exit was not ENABLE STARTED.
D. The database was disabled.
Ans:C
What is the name of the effect when a system continues to receive work, but is down?
A. Hutchins effect.
B. Auger effect.
C. Stormdrain effect.
D. Faraday effect.
Ans:C
Which statement about an index is NOT true?
A. An index always has a balanced tree structure.
B. A clustering index influences the physical sequence of data in the tablespace.
C. An index has its own INDEX SPACE, automatically created
D. The name of an index can be mentioned in a Select statement, to improve the performance of the query.
Ans:D
Which of the following can be accomplished with a single UPDATE statement?
A. Updating multiple tables based on a WHERE clause
B. Updating a view consisting of joined tables
C. Updating multiple tables
D. Updating a table based on a sub-select using joined tables
Ans:D
What must be done to a DB2 application before it can run, and why?
A. It has to be compressed first so it can recognize SQL statements.
B. It has to be binded first so it can recognize SQL statements.
C. It has to be encrypted first so it can recognize SQL statements.
D. It has to be compiled first so it can recognize SQL statements.
Ans:B
What is an example of a benefit of using the Java programming language?
A. Once you write the program, it can be used with any other program or software.
B. Once you write the program, it acts like a stored procedure.
C. Once you develop an application, it can be run anywhere.
D. There is no benefit to programming with Java.
Ans:C
When you don’t know the format of an SQL statement within a program you’re writing, what is a good option?
A. T-SQL.
B. NoSQL.
C. Dynamic SQL.
D. Static SQL.
Ans:C
When is it necessary to precompile DB2 REXX procedures before running them?
A. Every time because they use static SQL.
B. Only when you’re using a Java wrapper.
C. Never because they use dynamic SQL.
D. Only sometimes, because they vary from static to dynamic SQL.
Ans:C
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?
A. SELECT MYCURS INTO :HOSTMYTABLE:IND
B. FETCH * INTO :HOSTMYTABLE:IND FROM MYTABLE
C. FETCH MYCURS INTO :HOSTMYTABLE:IND
D. SELECT * INTO :HOSTMYTABLE:IND FROM MYCURS
Ans:C
Can static SQL statements be changed without altering the program itself?
A. Yes, but the program has to be altered.
B. Yes, but the statements have to be changed as well.
C. Yes. DB2 is a fully dynamic program, accepting all forms of SQL.
D. No.
Ans:D
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?
A. 2
B. 1
C. 3
D. 0
Ans:D
What is a benefit of concurrency in SQL application programming?
A. Increasing data access points.
B. Increase of data conflicts.
C. Minimization of data access conflicts.
D. Multi-threaded compiling.
Ans:C
How are ODBC calls binded?
A. They are not binded because they use standard functions to execute SQL.
B. They are binded at compile time.
C. They are pre-process binded.
D. They are binded using standard functions in SQL.
Ans:A
SQL statements embedded into an application is called what?
A. PL/SQL
B. Dynamic SQL.
C. T-SQL.
D. Static SQL.
Ans:D
Which of the following is not one of the types of authorizations associated with a DB2 user?
A. Current SQLID
B. Secondary Authorization ID
C. SQL Authorization ID
D. Primary Authorization ID
Ans:C
What’s the output of a DB2 Bind
A. DB2 Application plan
B. Database request module
C. DB2 Catalog
D. Load Module
Ans: A
How does one prepare a Java program that contains JDBC methods?
A. Use the “DB2java” command.
B. Use the “javac” command.
C. Use the “JBDC” command.
D. Use the “javago” command.
Ans: B
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?
A. B & E
B. The nullability of one of the included columns.
C. The data type of the included columns.
D. The order of the included columns.
Ans: B
Which of the following is true about the EXPLAIN command
A. EXPLAIN is used to display the access path as determined by the optimizer for a SQL statement
B. C,D & E
C. It can be used in SPUFI(for single SQL statement)
D. It can be used in BIND step(for embedded SQL).
Ans: B
In what catalog table must stored procedures be defined?
A. CONFPROC
B. SYSPROCEDURES
C. CONFPROCEDURES
D. STOPROCEDURES
Ans: B
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”?
A. 22xxx
B. 01xxx
C. 02xxx
D. 00xxx
Ans: C
What must a SELECT statement be coded within?
A. A DECLARE CURSOR.
B. A DEFINE CURSOR
C. A SELECT CURSOR
D. A STATIC CURSOR
Ans: A
What is an example of an underlying cause for regressions caused by changes in DB2?
A. Regression analysis.
B. Accurate statistics.
C. Inadequate statistics.
D. Redundant statistics.
Ans: C
Which of the following is a correct syntactical example of written SQL code?
A. TYPE INTO //:book_type FROM BOOK_TYPES WHERE//
B. EXEC SQL SELECT TYPE INTO :book_type FROM BOOK_TYPES WHERE
C. EXEC: SELECT INTO :book_type FROM BOOKTYPES WHERE
D. SELECT TYPE INTO :book_type FROM BOOK_TYPES WHERE
Ans: B
Which of the following is correct SQLJ syntax?
A. #sql [myConnCtxt] { UPDATE EMP
B. #sql [myConnCtxt] :: UPDATE//EMP
C. ///#sql [myConnCtxt]}}{{||\\ { UPDATE EMP///
D. #//sql [myConnCtXt] { update EMP
Ans: A
How many indexes will be created by the following statement? Create table Smarterer { Col1 int not null primary key, Col2 char (64), Col3 char (32), Col4 int not null, Constraint c4 unique (Col4,Col1) }
A. 1
B. 2
C. 0
D. 3
Ans: B
Which of the following is not a DB2 object
A. Storage Group
B. Table
C. Synonym
D. Column
Ans: D
What are the maximum number of tables that can be joined in DB2
A. 15
B. 16
C. 12
D. 10
Ans: A
What happens when the execution of a utility is terminated by the TERM command?
A. The execution ends abnormally, the corresponding row in the SYSUTIL table is not removed, all resources are freed.
B. The execution ends normally, the corresponding row in the SYSUTIL table is not removed, all resources are freed.
C. The execution ends abnormally, the corresponding row in the SYSUTIL table is removed, all resources are freed.
D. The execution ends normally, the corresponding row in the SYSUTIL table is removed, all resources are freed.
Ans: D
Can the SQL procedural language be used for advanced functions?
A. Yes, but with a supplementary set of Java wrappers.
B. Yes, but they must be precompiled first.
C. Yes, but with some supplementary coding.
D. No.
Ans:D
What happens to SQL statements if there are no stored procedures?
A. They are disregarded.
B. They are embedded.
C. They are locked.
D. They are corrupted.
Ans: B
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
A. INSERT INTO Smart1 VALUES (200, 2, 3)
B. INSERT INTO View1 VALUES (250, 2, 3)
C. INSERT INTO View1 VALUES (300, 2, 3)
D. INSERT INTO Smart1 VALUES (350, 2, 3)
Ans:C
Why must the DB2 precompiler be used to execute SQL statements?
A. It isn’t necessary to use the DB2 precompiler.
B. The DB2 precompiler wraps the SQL statements in Java for easier use.
C. The DB2 precompiler executes a HIVE database for SQL operation.
D. The compiler does not recognize SQL statements.
Ans: D
What is the Java data access platform used in DB2?
A. pureQuery.
B. aQuery.
C. dQuery.
D. jQuery.
Ans: A
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’?
A. You can’t insert into a view, because views don’t contain actual data; they’re just virtual windows on base tables.
B. The row won’t be inserted because the field STATE doesn’t have the value ‘MA’.
C. The row will be inserted in the table S001.TEAMS, but it will never show up in a SELECT on this view.
D. The row will be inserted only if the user has an authority to insert on table S001.TEAMS, but it will never show up in a SELECT on this view.
Ans: C
When should we execute a REBIND rather than a BIND
A. C & E
B. When the embedded SQL of the application is changed.
C. When an index is added to one of the tables used by the embedded SQL.
D. After the execution of a RUNSTATS.
Ans: A
Which statement about tablespaces is true?
A. When creating a tablespace, one must indicate either the storage group or the bufferpool to be used by this tablespace. If neither is defined, the creation of the tablespace will fail.
B. A tablespace is divided in units called pages , which hold one or more rows of a table. If a row of 8000 bytes is placed in a 4K page, th e row will automatically be split over two pages.
C. 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.
D. A tablespace is divided in units called pages , which hold one or more rows of a table. If a row of 8000 bytes is placed in a 4K page, the page will automatically be resized to 8K.
Ans: C
What four languages can host variable arrays be specified in?
A. C, C++, COBOL, or PL/I.
B. C, C++, Fortran, or PL/I.
C. Javascript, C++, COBOL, or PL/I.
D. C, C++, Perl, or PL/I.
Ans: A
Which of the following represents a function that is performed for each row in a DB2 table
A. Aggregate Function
B. Group by Having
C. Group by
D. Scalar function
Ans: D
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?
A. There is still a single null allowed, since it is unique as such.
B. It has no influence on the possible null values; DB2 doesn’t consider nulls when it comes to an index.
C. C & F
D. Nulls are no longer allowed, since nulls aren’t unique.
Ans: A
Which is an example of a column that would contain statistics necessary for programming?
A. CRDF
B. CARDF
C. CRDX
D. CARDY
Ans: B
Which of the following is not a type of dynamic SQL?
A. Deferred embedded SQL.
B. Interactive SQL.
C. Embedded dynamic SQL.
D. Enhanced PL/SQL
Ans: D
Which of the following statements concerning locking on TABLESPACE level is correct?
A. When a TABLESPACE is S-locked by another user, a U lock can be placed. However, an X lock is not compatible. A IX lock (Intent to eXclusively use) will be placed to indicate that a X lock is waiting to be placed.
B. When a TABLESPACE is S-locked by another user, neither a U lock or an X lock is com- patible on this level. In both cases an I lock (IU lock, IX lock) will be placed to indicate that a U lock or X lock is waiting to be placed.
C. 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.
D. When a TABLESPACE is S-locked (Shared use) by another user, a U lock (Update use) can be placed. However, an X lock (eXclusive use) on this level will force the S lock to be dropped, its transaction to be rolled-back to be able to place the X lock.
Ans: C
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?
A. UPDATE T001.CLASSS SET CDUR = 5 WHERE CURRENT OF CLASSUPDATE
B. UPDATE T001.CLASSS C SET C.CSTITLE = ‘New Title’ WHERE CURRENT OF CLASSUPDATE
C. UPDATE SET CDUR = 5 WHERE CURRENT OF CLASSUPDATE
D. UPDATE T001.CLASSS SET CDUR = 5
Ans: A
If the SQLCA is included in the program, which of the following host-variables is NOT known and as such unavailable for the program?
A. SQLCODE
B. SQLSTATE
C. SQLWARN
D. SQLNUM
Ans: D
Which of the following is not a DB2 datatype
A. Vargraphic
B. Long Graphic
C. Long Vargraphic
D. Graphic
Ans: B
Which subquery operator compares a single value to every member of set of value.
A. Between
B. In
C. All
D. Any
Ans: D
Any database needs to go through a normalization process to make sure that data is represented only once. This will eliminate problems with creating or destroying data in the database. The normalization process is done usually in three steps which results in first, second and third normal forms. Which best describes the process to obtain the third normal form?
A. Each table should have related columns.
B. Each separate table should have a primary key.
C. If a table has columns not dependent on the primary keys, they need to be moved in a separate table.
D. We have a table with multi-valued key. All columns that are dependent on only one or on some of the keys should be moved in a different table.
Ans: C
When using JBDC, do you have to recode your Java application if you want to change between drivers?
A. No, however the new drivers need wrappers.
B. Yes, however there is a tool that must be used to change to a new driver.
C. No.
D. No, however a special code must be written to use a new driver.
Ans: C
In what form is data physically stored in DB2
A. VSAM ESDS
B. Flat Files
C. VSAM LDS
D. Tables
Ans: C
SELECT empname , paygrade , salary FROM emp, salgrade WHERE salary BETWEEN lowsal AND highsal ORDER BY paygrade The above is an example of a
A. Non equi join
B. Inner join
C. None of the above
D. Outer join
Ans: A
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?
A. IND, STUDNAME, CLASSNAME
B. SQLCODE, STUDNAME, CLASSNAME
C. SQLCODE, CLASSNAME, IND
D. SQLCODE, IND, CLASSNAME
Ans: D
Besides on TABLE and TABLESPACE level, on what level can implicit locks be placed by DB2?
A. On ROW,PAGE and PARTITION level
B. On PAGE , SEGMENT and PARTITION level.
C. On PAGE , SEGMENT and PARTITION level.
D. On ROW , PAGE and SEGMENT level.
Ans: A
When can you not drop a database
A. Before all indexes connected to tables of this database are dropped.
B. If there is still a user connected to the database.
C. If there is a referential constraint pointing to a table of this database from a table of another database.
D. When a DB2 utility has control of any part of the database.
Ans: D