sqldatabaseindexingconstraintsrelational-database

What is the difference between primary, unique and foreign key constraints, and indexes?


What is the difference between primary, unique and foreign key constraints, and indexes?

I work on Oracle 10g and SQL Server 2008.


Solution

  • Primary Key and Unique Key are Entity integrity constraints

    Primary key allows each row in a table to be uniquely identified and ensures that no duplicate rows exist and no null values are entered.

    Unique key constraint is used to prevent the duplication of key values within the rows of a table and allow null values. (In oracle one null is not equal to another null).

    see Differences between INDEX, PRIMARY, UNIQUE, FULLTEXT in MySQL?