Junior From PDF SQL SQL & Databases

What is the difference between a unique index and a primary key index?

  • Unique Index:
  • Ensures that the values in the indexed columns are unique.
  • Can be created on any column and allows NULL values (in most DBMS).
  • A table can have multiple unique indexes.
  • Primary Key Index:
  • Enforces the uniqueness of the column(s) and also guarantees NOT NULL

constraint on the column(s).

  • A table can only have one primary key.
  • Automatically creates a unique index.

In short, both enforce uniqueness, but the primary key also guarantees that the column(s)

cannot be NULL.

More from SQL Server Tutorial

All questions for this course
Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details