DB2 - Session04 1
DB2 - Session04 1
DB2 – Session 4
DB2 2
Static SQL
Dynamic SQL
Indexes
What is an Index ?
‘An index is an ordered set of pointers to rows of a
base table’.
Or
‘An Index is a balanced B-tree structure that orders
the values of columns in a table’
Why an Index ?
‘One can access data directly and more efficiently’
DB2 5
Indexes (contd...)
• Each index is based on the values of data in one or
more columns. An index is an object that is separate
from the data in the table.
• When you define an index using the CREATE INDEX
statement, DB2 builds this structure and maintains it
automatically.
• Indexes can be used by DB2 to improve performance
and ensure uniqueness.
• In most cases, access to data is faster with an index.
• A table with a unique index cannot have rows with
identical keys.
DB2 6
Indexes (contd...)
Syntax : For creation of an Index
VIEWS
• It is a logical derivation of a table from other
table/tables. A View does not exist in its own right.
• They provide a certain amount if logical independence
• They allow the same data to be seen by different users
in different ways
• In DB2 a view that is to accept a update must be
derived from a single base table
DB2 14
Synonym
• Also means another name for the table, but is private to
the user who created it.
DB2 15