Difference between primary key and unique key ? Difference between index and primary key
Answers
Answered by
4
Primary Key (PK): It's also a column or group of columns that can identify a uniqueness in a row. So the Primary key is just another name for unique key, but the default implementation in SQL Server is different for Primary andUnique Key. By Default: PK creates a Clustered index and UK creates a Non Clustered Index.
Attachments:
Answered by
0
Primary Key:
1) There can only be one primary key in a table
2) In some DBMS it cannot be NULL - e.g. MySQL adds NOT NULL
3) Primary Key is a unique key identifier of the record
Unique Key:
1) Can be more than one unique key in one table
2) Unique key can have NULL values
It can be a candidate key
3) Unique key can be NULL and may not be unique
The Primary Key is a logical object. By that I mean that is simply defines a set of properties on one column or a set of columns to require that the columns which make up the primary key are unique and that none of them are null. Because they are unique and not null, these values (or value if your primary key is a single column) can then be used to identify a single row in the table every time. In most if not all database platforms the Primary Key will have an index created on it.
An index on the other hand doesn’t define uniqueness. An index is used to more quickly find rows in the table based on the values which are part of the index. When you create an index within the database, you are creating a physical object which is being saved to disk. Using a table which holds employees.
Hope this will help you... ✌
1) There can only be one primary key in a table
2) In some DBMS it cannot be NULL - e.g. MySQL adds NOT NULL
3) Primary Key is a unique key identifier of the record
Unique Key:
1) Can be more than one unique key in one table
2) Unique key can have NULL values
It can be a candidate key
3) Unique key can be NULL and may not be unique
The Primary Key is a logical object. By that I mean that is simply defines a set of properties on one column or a set of columns to require that the columns which make up the primary key are unique and that none of them are null. Because they are unique and not null, these values (or value if your primary key is a single column) can then be used to identify a single row in the table every time. In most if not all database platforms the Primary Key will have an index created on it.
An index on the other hand doesn’t define uniqueness. An index is used to more quickly find rows in the table based on the values which are part of the index. When you create an index within the database, you are creating a physical object which is being saved to disk. Using a table which holds employees.
Hope this will help you... ✌
Similar questions
Hindi,
7 months ago
Computer Science,
7 months ago
Political Science,
7 months ago
Math,
1 year ago
Hindi,
1 year ago
Science,
1 year ago