What is the differences between primary & foreign key?

Primary Key
Foreign Key
1 – Primary key uniquely identify a record in the table. Foreign key is a field in the table that is primary key in another table.
2 – Primary Key can’t accept null values. Foreign key can accept multiple null value.
3 -By default, Primary key is clustered index and data in the database table is physically organized in the sequence of clustered index. Foreign key do not automatically create an index, clustered or non-clustered. You can manually create an index on foreign key.
4 -We can have only one Primary key in a table. We can have more than one foreign key in a table.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Blog at WordPress.com.

Up ↑

%d bloggers like this: