Saturday, October 23, 2021

Difference between SQL Primary Key and Candidate Key in Oracle

  • Primary Key:
    • A Primary Key is a column or a combination of columns that uniquely identify a record. Only one Candidate Key can be Primary Key.
  • Candidate Key: 
    • A Candidate Key can be any column or a combination of columns that can qualify as unique key in database. 
    • There can be multiple Candidate Keys in one table. 
    • Each Candidate Key can qualify as Primary Key.
One needs to be very careful in selecting the Primary Key as an incorrect selection can adversely impact the database architect and future normalization. For a Candidate Key to qualify as a Primary Key, it should be Non-NULL and Unique in any domain.

No comments:

Post a Comment

Query To Fetch AP Invoice Details From SO Number(Doc ID 2949013.1)

SELECT dh.source_order_number       ,df.source_line_number as so_line_number   ,df.fulfill_line_number    ,ddr.doc_user_key as po_number...