0% found this document useful (0 votes)
70 views1 page

Primary Key

Primary keys uniquely identify records in a table and cannot contain null values or duplicate values. In contrast, foreign keys are fields that match the primary key of another table and can contain multiple null values. Primary keys automatically create a clustered index by default to organize the table's data physically, whereas foreign keys do not automatically create indexes and indexes must be manually added.

Uploaded by

Animesh Sonwane
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
70 views1 page

Primary Key

Primary keys uniquely identify records in a table and cannot contain null values or duplicate values. In contrast, foreign keys are fields that match the primary key of another table and can contain multiple null values. Primary keys automatically create a clustered index by default to organize the table's data physically, whereas foreign keys do not automatically create indexes and indexes must be manually added.

Uploaded by

Animesh Sonwane
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Primary key Foreign Key

Primary key uniquely identify a record in the table. Foreign key is a field in the table that is primary key in another table.

Primary Key can't accept null values. Foreign key can accept multiple null values.

By default, Primary key is clustered index and data in the database table is Foreign key do not automatically create an index, clustered or non-clustered.
physically organized in the sequence of clustered index. You can manually create an index on foreign key.

We can have only one Primary key in a table. We can have more than one foreign key in a table.

Primary Key Unique Key

Primary Key can't accept null values. Unique key can accept only one null value.
By default, Primary key is clustered index and By default, Unique key is a unique non-clustered
data in the database table is physically organized index.
in the sequence of clustered index.
We can have only one Primary key in a table We can have more than one unique key in a
table
Primary key can be made foreign key into In SQL Server, Unique key can be made foreign
another table key into another table.

You might also like