Unique index && PRIMARY key index

Source: Internet
Author: User

Unique index
A unique index does not allow two rows to have the same index value.

If duplicate key values exist in the existing data, most databases do not allow the newly created unique index to be saved with the table.

The database also rejects this data when the new data duplicates the key values in the table. For example, if a unique index is created on the employee's last name (lname) column in the Employee table, all employees cannot have the same surname.

Primary key Index
A primary key index is a special type of unique index.
A database table typically has a column or combination of columns whose values are used to uniquely identify each row in the table. This column is called the primary key of the table.
Defining a primary key for a table in a database diagram automatically creates a primary key index. The primary key index requires that each value in the primary key be unique. When a primary key index is used in a query, it also allows for fast access to the data.

Some of their comparisons:
(1) for the main jian/unique constraint, Oracle/sql server/mysql and so on will automatically establish a unique index;
(2) The primary key does not necessarily contain only one field, so if you Jianjian a unique index in one of the primary keys, it is necessary;???
(3) Primary key can be used as external health, the unique index is not;
(4) The primary key cannot be empty, the unique index can be;
(5) The primary key is also a combination of multiple fields;
(6) There can be only one primary key per table.

Unique index && PRIMARY key index

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.