Computer Science, asked by ranish4975, 1 year ago

What Is Difference Between Unique Constraint And Primary Key Constraint ?

Answers

Answered by EHSASS
4

★彡 ʜᴇʀᴇ ɪs ʏᴏᴜʀ ᴀɴsᴡᴇʀ 彡★

The PRIMARY Key and UNIQUE Key constraints, both are similar and enforce uniqueness of the column on which they are defined.

Primary Key

⭐️Primary key cannot have a NULL value.

⭐️Each table can have only one primary key.

⭐️By default, Primary key is clustered index, and the data in database table is physically organized in the sequence of clustered index.

⭐️Primary key can be related to another tables as a Foreign Key.

⭐️We can generate ID automatically with the help of Auto Increment field. Primary key supports Auto Increment value.

⭐️We can define Primary key constraint on temporary table and table variable.

⭐️We can't delete primary key value from the parent table which is used as a foreign key in child table. To delete we first need to delete that primary key value from the child table.

Unique Key

⭐️Unique Constraint may have a NULL value.

⭐️Each table can have more than one Unique Constraint.

⭐️By default, Unique key is a unique non-clustered index.

Unique Constraint can not be related with another table's as a Foreign Key.

ᴇʜsᴀss 彡★

Answered by Anonymous
1

The difference between a UNIQUE constraint and a Primary Key is that per table you may only have one Primary Key but you may define more than one UNIQUE constraints. Primary Key constraints are not nullable. UNIQUE constraints may be nullable. ... A UNIQUE constraint will generate a unique NON-CLUSTERED INDEX.

Similar questions