Database indexing? mysql index? The difference between primary key index and unique index?

 Index is a structure of values in a database table in one or more columns to sort of specific information database using the index for quick access to the database table index is like a book in front of the catalog, you can speed up database query speed.

The general index ,

Primary key index , ( requiring each primary key values are unique. )

Unique index , ( unique index index is not allowed any two rows having the same index value. )

Composite index,

Full-text indexing .

  the difference:

1. After you create a primary key must contain a unique index, a unique index is not necessarily the primary key.

 

2. unique index column allows null values, and the primary key column does not allow nulls.

 

3. When you create a primary key column has a default value is null + a unique index.
4. The primary key can be referenced by other table as a foreign key, but not unique index.
5. A table can create up to a primary key, but you can create multiple unique index.
6. The primary key uniquely identifies more suitable for those who are not easy to change, such as auto-increment columns, ID number and so on.
7. Under RBO mode, the primary key of the implementation plan takes precedence over a unique index. The two can improve the speed of queries. 

 

Guess you like

Origin www.cnblogs.com/dsds/p/11539583.html