Wednesday 13 March 2013

DDL - Part 3 - Primary key and Primary index difference


Primary Key And Primary Index Difference:

Primary Key
Primary Index
One or More column used to uniquely identify table rows
One or more columns used to Distribute and locate rows on the AMPs
Used along with Foreign Key to Define table relationships.
Used to affect Distribution, access and Performance
Pk is always Unique (ND-No duplicates)
Primary index can be Unique or Non Unique (UPI and NUPI)
PK cannot be NULL (NN- Not NULL)
Primary index can contain NULL. If its UPI then only one row can have null for PI and if its NUPI, multiple rows can have NULL.
PK value cannot be changed ( NC- No change)
Primary Index value can be changed. This will lead to redistribution of data.
PK can be dropped and recreated using ALTER TABLE command
Primary index cannot be recreated without dropping and recreating the table.

No comments:

Post a Comment