V – view
DATA TYPES :
Integer -- 4 bytes
Char(n) – N bytes
Graph(n) – 2n bytes
Date – 10 bytes
Time – 8 bytes
Timestamp – 26 bytes
NORMALIZATION :
Foreign key : -
INO INTEGER,
INAME CHAR(15),
CNO INTEGER,
Grant, Revoke
Commit, Rollback
Column functions:
SUBQUERY:
CO-RELATED SUBQUERY:
• For every row of outer query, inner query must
executes at least once
• First outer query executes & then inner query executes
• Practical examples : to fine top 2,3 or n salaries
1. -- max
2. – 2nd max
3. – 3rd max
4. – 4th max
DCLGEN :
Exec sql
Inlcude custDCL
End-exec.
SQLCODE :
Sample program:
WORKING-STORAGE SECTION.
EXEC SQL
INCLUDE SQLCA
END-EXEC
EXEC SQL
INCLUDE CUSTDCL
END-EXEC.
88 88-SUCCESS VALUE 00
UPDATE CUST
WHERE CNO=:HV-CNO
EVALUE WS-SQL-CODE
WHEN 88-SUCCESS
WHEN 88-NOTFOUND
WHEN 88-FOREIGNKEYVOILATION
WHEN OTHER
STOP RUN
END-EVALUATE.
STOP RUN.
CURSOR:
To retrieve multiple rows for a given condition.
Exec sql
Select cno,cname,cloc
into :hv-cno,:hv-cname,:hv-cloc
end-exec.
EXEC SQL
WHERE CNAME=:HV-CNAME
END-EXEC.
EXEC SQL
OPEN C1.
END-EXEC.
EXEC SQL
END-EXEC
END-PERFORM.
EXEC SQL
CLOSE C1
END-EXEC
WHERE CNAME=:HV-CNAME
END-EXEC.
EXEC SQL
OPEN C1.
END-EXEC.
EXEC SQL
END-EXEC
EXEC SQL
EMD=EXEC.
EXEC SQL
CLOSE C1
END-EXEC
INDEX:
• Index allows duplicate values
• unique index doesn’t allow duplicate rows
• cross reference between index table & table is called
clustered index.
• Create index in1 on cust(cno)
VIEWS:
CREATE VIEW CVIEW(VCNO,VCNAME,VCLOC) AS
Advantages of Views:
• Data security
• Data correctness
• Logical data independence
• Part of the information can be visible to the sers
• Accessing can be faster.
DELETE RULES:
UNION:
UNION/UNIONALL
JOINS:
EXPLAIN :
Plan table
DB2 CATALOG:
SysIBM.SYSTABLE
SysIBM.SYSINDEX
Index Table No.of Owner Created Created Created
name Name cols name by date time
SysIBM.SYSCOLS
PRECOMPILATION PROCESS:
Precompiler functions:
BIND:
BIND takes DBRM as input & generate package & application
plan. The package will be loaded to the directory. Plan will be
loaded to sysplans.
Bind functions:
BIND SUBCOMPONANTS/PARAMETERS:
1. OPTIMIZER:
o It generates optimized access path by analyzing
the statistics of SQL statements which will be
stored.
o RUNSTATS utility is one of the ISPF panel option
which is stored in DB2 defaults option.
o Optimized path is stored in package which is not
executable module.
2. ISOLATION LEVEL:
Default is RR.
3. RUNTIME SUPERVISOR:
4. PLAN/APPLICATION PLAN:
COBOL COMPILATION:
The compiler takes COBOL statement as input to generate
object program, & loaded to the load module by line/edit
with time stamp tokens.
UTILITIES USED: