FAQs(31 to 45)

31) How is the SUBSTR keyword used in SQL?

A) SUBSTR is used for string manipulation with column name, first position and string length used as arguments. E.g.

SUBSTR (NAME, 1 3) refers to the first three characters in the column NAME.

32) Explain the EXPLAIN statement?

A) The explain statement provides information about the optimizer's choice of access path of the SQL.

33) What is referential integrity?

A) Referential integrity refers to the consistency that must be maintained between primary and foreign keys, i.e. every

foreign key value must have a corresponding primary key value.

34) What is a NULL value? What are the pros and cons of using NULLS?

A) A NULL value takes up one byte of storage and indicates that a value is not present as opposed to a space or zero

value. It's the DB2 equivalent of TBD on an organizational chart and often correctly portrays a business situation.

Unfortunately, it requires extra coding for an application program to handle this situation.

35) What is a synonym? How is it used?

A) A synonym is used to reference a table or view by another name. The other name can then be written in the

application code pointing to test tables in the development stage and to production entities when the code is migrated.

The synonym is linked to the AUTHID that created it.

36) What is an alias and how does it differ from a synonym?

A) An alias is an alternative to a synonym, designed for a distributed environment to avoid having to use the location

qualifier of a table or view. The alias is not dropped when the table is dropped.

37) When can an insert of a new primary key value threaten referential integrity?

A) Never. New primary key values are not a problem. However, the values of foreign key inserts must have

corresponding primary key values in their related tables. And updates of primary key values may require changes in

foreign key values to maintain referential integrity.

38) What is the difference between static and dynamic SQL?

A) Static SQL is hard-coded in a program when the programmer knows the statements to be executed. For dynamic SQL

the program must dynamically allocate memory to receive the query results.

39) Compare a subselect to a join?

A) Any subselect can be rewritten as a join, but not vice versa. Joins are usually more efficient as join rows can be

returned immediately, subselects require a temporary work area for inner selects results while processing the outer

select.

40) What is the difference between IN subselects and EXISTS subselect?

A) If there is an index on the attributes tested an IN is more efficient since DB2 uses the index for the IN. (IN for index is

the mnemonic).

41) What is a Cartesian product?

A) A Cartesian product results from a faulty query. It is a row in the results for every combination in the join tables.

42) What is a tuple?

A) A tuple is an instance of data within a relational database.

43) What is the difference between static and dynamic SQL?

A) Static SQL is compiled and optimized prior to its execution; dynamic is compiled and optimized during execution.

44) Any SQL implementation covers data types in couple of main categories. Which of the following are those data

types ? (Check all that apply)

A). NUMERIC

B). CHARACTER

C). DATE AND TIME

D). BLOBS E. BIT

A) A,B,C. Not all SQL implementations have a BLOB or a BIT data types.

45) We have a table with a CHARACTER data type field. We apply a ">" row comparison between this field and

another CHARACTER field in another table. What will be the results for records with field value of NULL?

(Check one that applies the best)

A. TRUE

B. B. FALSE

C. C. UNKNOWN

D. D. Error.

E. E. Those records will be ignored

A) C. NULL in a row when compared will give an UNKNOWN result.