DB2

DB2 is IBM's offering to the highend database market. The latest version of DB2 (Universal Database) is ideal for OLTP, Data Warehousing, Decision Support and everything in between. It's well priced, extremely scalable and runs on virtually every platform out there from handhelds to mainframes.

keys and indexes


How do you decide when to use primary key vs. unique key and primary index vs. unique index?
A primary key must have a unique index on the same columns. If one doesn't already exist, DB2 will create one when then PK is created.
Functionly within DB2 there is usually not much difference between a Uniquie Constraint and a Primary Key Constraint (with some minor exceptions). The difference has more to do with the theory of data modeling and Third Normal Form design. A table can have only one PK, but multiple Unique Constraints.
one difference is pk's column must be defined as not null。
And I also remember ( but not sure ), DB2 tries to organize table's data with the same sequence of pk, that means db2 always try to keep a relative higher clustor ratio of PK when there is not any other cluster index on the table.
Originally Posted by fengsun2
one difference is pk's column must be defined as not null。
And I also remember ( but not sure ), DB2 tries to organize table's data with the same sequence of pk, that means db2 always try to keep a relative higher clustor ratio of PK when there is not any other cluster index on the table.
Not in DB2 LUW. If no clustering index is defined, then DB2 does not order the rows for inserts or reorg (unless a specific index is named during a reorg).
On DB2 z/OS the first index defined is used as the clustering index, unless another index is specifically chosen by the DBA. Usually the PK index is the first one defined, so maybe that is what you were thinking. There may be an override available in newer versions of DB2 z/OS so there is not any default clustering index, but not sure about that.

Related Links

URGENT - copye a full database
Stupid question
DB2 Backup with TSM failing with SQL2062N and Reason Code 610
Task Center - User Interface Scheduling
Full tablescan
ON DELETE RESTRICT vs ON DELETE NO ACTION
DB2 scheduled backup
DB2 Performance problem
Fetch in DB2 stored procedure
how can I start "db2cc"!
query optimizer runs astray....
Migration AS/400 DB2 to Windows DB2 8.1
Creating a new database with the existing database with same structure
load error SQL0302N
load error SQL0302N
Db2 Udb Unix Aix

Categories

DataBase Dev
MongoDB
Adabas
DB2
Informix
Microsoft SQL Server
MySQL
Oracle
Pervasive.SQL
PostgreSQL
Sybase
Other
ASP
Crystal Reports
Delphi, C etc
JAVA
Perl and the DBI
PHP
ANSI SQL
Unix Shell Scripts
Visual Basic
Brilliant Database
Corel Paradox
FileMaker
Microsoft Access
Microsoft Excel
Other PC Databases
New Members & Introduc...
Applications & Tools
Database Concepts & De...
Chit Chat
Marketplace
Job Opportunities
Suggestions & Feedback

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App