DB2 Flashcards

(35 cards)

0
Q

Explain Second Normal Form

A

Non key columns provide a fact about the key.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
1
Q

Explain First Normal form

A

All occurrences of a record should contain the same number of records.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Explain 3rd normal Form.

A

Each non key column is independent of other non key columns and is dependant only on the key.
Each non key column must provide a fact about the key.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Explain 4th Normal Form

A

No row contains 2 or more independent multi-valued facts about an entity.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Explain stage 1 and stage 2 predicates

A

Stage 1
Sarge able (searchable argument) Uses the data manager (DM)
Stage 2
Non Sargeable , non indexable, uses RDS

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

SQL - How would you find out the total rows on a DB2 table?

A

SELECT COUNT(*) WITH UR

Or

Check catalog RTS if re-orged regularly.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

SQL - How do you eliminate duplicate values in SQL.

A

SELECT DISTINCT or preferably, ensure predicate uses full key

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

SQL - How would you find the highest value for a column?

A

SELECT MAX(col name)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

SQL - How would you select the first five characters of the column FIRSTNAME of Table EMP.

A
SELECT SUBSTR(FIRSTNAME,1,5)
FROM EMP
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

SQL - How would you concatenate FIRSTNAME and LASTNAME in SQL to give a complete name.

A

Select Strip(FIRSTNAME) CONCAT “ “ CONCAT strip(LASTNAME) as FULLNAME

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

SQL - How would you list employees who are not assigned to a project.

A

SELECT FIRSTNAME
,LASTNAME
FROM. EMP
WHERE PROJECT IS NULL

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Explain CS,RR and UR.

A

Cursor Stability
Locks released on page at once

Repeatable Read
Locks retained until end of transaction

Uncommitted Read
No locks

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Describe the physical storage of
DATE
TIME
TIMESTAMP

A

Physical
DATE 4 Bytes
TIME 3 Bytes
TIMESTAMP 10 Bytes

Layout
DATE CHAR(08)
TIME CHAR(06)
TIMESTAMP CHAR(26)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Name the various locking levels.

A

Row
Page
Table
Table space

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

SQL - What would you accomplish with GROUP BY and HAVING.

A

GROUP BY will display groups of data with their aggregate function result.
HAVING will restrict the result to those that satisfy the HAVING clause.

I.e HAVING count(*) > 1.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is a cursor, why is it used.

A

Used in COBOL program when the result of a query will retrieve more than one row.

DECLARE Cursor
OPEN Cursor

PERFORM until no more
FETCH Cursor
END PERFORM

Close Cursor

16
Q

Describe UNION all

A

UNION

Will return the result of 2 separate queries which retrieve identical columns, deduplicating rows.

UNION ALL

Will not remove duplicates.

17
Q

Describe what happens at the statement OPEN Cursor

A

Cursor placed on first row unless an order by is used, then all rows are retrieved and sorted.

18
Q

SQL - can MAX be used on a CHAR column?

19
Q

SQL - the following statement is returning inaccurate results, offer possible reasons why?

A

Check definition of SALARY, are NULLS allowed?

20
Q

What is the largest value a BIGINT column can hold?

A

8 bytes

9 quintillion

21
Q

Describe aggregate functions and provide examples

A

Built in maths functions like

SUM
COUNT
MAX

22
Q

How would you select a row using the index.

A

Use all unique key columns in predicate.

23
Q

Version 9

New features.

A
OLAP processing
RANK
DENSE RANK
ROW NUMBER
Optimising sub queries
DATA TYPE XML
24
What is a correlated sub query.
A sub query where the inner query refers to the table in the outer query.
25
Version 10 Features
``` Enhanced User Degined Functions SELECT IN RETURN TIMESTAMP extension TIMEZONE UTC Temporal tables DSNULI XML modify Progressive LOB streaming Online reorganise of LOBS ```
26
``` Expand the following DDL DML DCL SQL ```
``` DDL - Data Definition Language Create Database, Table space Table Etc. DML - Data Modification Language DCL - Data Control Language I.E. DCLGEN SQL - Structured Query Language. ```
27
Explain 2 phase commit.
``` DB2 updates Logs - Retains locks CICS update logs - Retains Locks DB2 log commit - release locks CICS release locks Log 2 phase commit record. ```
28
What is a scalar query
Returns 1 result 1 row and 1 column.
29
SQLCODE -805
-805. Package not found in plan. -818. Plan load mismatch , DBRM different to load module. -911 resource unavailable -913 deadlock -904 resource unavailable +100 Row not found
30
Explain different access types
Direct Index lookup Matching index scan Non matching index scan
31
SQL - UNION What is the restriction of using UNION in an SQL statement.
Must be used within a cursor
32
Explain difference between II and BETWEEN
IN(1,4,7) BETWEEN 1 AND 7 IN specifies a list BETWEEN specifies a range.
33
DCL Show example of definition of a VARCHAR column
10 REMARKS 49. REMARKS-LEN PIC S9(4) COMP. 49 REMARKS-TEXT PIC X(1926)
34
Describe - Indoubt thread.
In a connection failure or system crash, the commit status of some threads may be unresolved. When CICS and DB2 are restarted, these are either resolved automatically or by using RECOVER INDOUBT.