DB2 Flashcards
(35 cards)
Explain Second Normal Form
Non key columns provide a fact about the key.
Explain First Normal form
All occurrences of a record should contain the same number of records.
Explain 3rd normal Form.
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.
Explain 4th Normal Form
No row contains 2 or more independent multi-valued facts about an entity.
Explain stage 1 and stage 2 predicates
Stage 1
Sarge able (searchable argument) Uses the data manager (DM)
Stage 2
Non Sargeable , non indexable, uses RDS
SQL - How would you find out the total rows on a DB2 table?
SELECT COUNT(*) WITH UR
Or
Check catalog RTS if re-orged regularly.
SQL - How do you eliminate duplicate values in SQL.
SELECT DISTINCT or preferably, ensure predicate uses full key
SQL - How would you find the highest value for a column?
SELECT MAX(col name)
SQL - How would you select the first five characters of the column FIRSTNAME of Table EMP.
SELECT SUBSTR(FIRSTNAME,1,5) FROM EMP
SQL - How would you concatenate FIRSTNAME and LASTNAME in SQL to give a complete name.
Select Strip(FIRSTNAME) CONCAT “ “ CONCAT strip(LASTNAME) as FULLNAME
SQL - How would you list employees who are not assigned to a project.
SELECT FIRSTNAME
,LASTNAME
FROM. EMP
WHERE PROJECT IS NULL
Explain CS,RR and UR.
Cursor Stability
Locks released on page at once
Repeatable Read
Locks retained until end of transaction
Uncommitted Read
No locks
Describe the physical storage of
DATE
TIME
TIMESTAMP
Physical
DATE 4 Bytes
TIME 3 Bytes
TIMESTAMP 10 Bytes
Layout DATE CHAR(08) TIME CHAR(06) TIMESTAMP CHAR(26)
Name the various locking levels.
Row
Page
Table
Table space
SQL - What would you accomplish with GROUP BY and HAVING.
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.
What is a cursor, why is it used.
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
Describe UNION all
UNION
Will return the result of 2 separate queries which retrieve identical columns, deduplicating rows.
UNION ALL
Will not remove duplicates.
Describe what happens at the statement OPEN Cursor
Cursor placed on first row unless an order by is used, then all rows are retrieved and sorted.
SQL - can MAX be used on a CHAR column?
Yes.
SQL - the following statement is returning inaccurate results, offer possible reasons why?
Check definition of SALARY, are NULLS allowed?
What is the largest value a BIGINT column can hold?
8 bytes
9 quintillion
Describe aggregate functions and provide examples
Built in maths functions like
SUM
COUNT
MAX
How would you select a row using the index.
Use all unique key columns in predicate.
Version 9
New features.
OLAP processing RANK DENSE RANK ROW NUMBER Optimising sub queries DATA TYPE XML