In fact, the index of a specified column is equivalent to sorting the specified column. Why? Because sorting is conducive to querying this column, it can greatly increase the query efficiency. (Some people may think that sorting all columns can increase the query efficiency of the entire database? This idea is wrong because index creation also consumes system resources. Creating an index for each column in each table will cause a great burden on the system, let alone efficiency !) --------- Simply put, creating a column index is equivalent to creating a column sort.
The primary key is actually an index, but this index is different from the general index. The difference is that every record in the column where the primary key is located is unique, it can also be said that the same record cannot appear in the primary key, and only one primary key can exist in the same table. (The primary key is equal to the index, and the index is not necessarily equal to the primary key) ---------- simply put, the primary key is a special index where the same record cannot appear in the column, and this index can only appear once in the table. Www.2cto.com 1. the primary key must be a unique index, and the unique index is not necessarily a primary key; 2. A table can have multiple unique indexes, but only one primary key. 3. the primary key column does not allow null values, while the unique index column does. The primary key has a unique identifier in the table. It cannot be repeated and cannot be blank. When a foreign key is set up in other tables to associate the current table, only the primary key can be associated. Unique index. Specifically, it is a unique constraint. create unique index index_id on (id) is a field used to restrict the unique constraints created when the current table is inserted. One is used as a unique identifier, and the other is used as a unique identifier.
From column simonjay2007