MySQL index classification and use

Source: Internet
Author: User

One, MySQL: index in B-Tree format save

The memory storage engine can select either a hash or a btree index, and the hash index can only be used for = or <=> equality comparisons.

1. Normal index: CREATE index on TableName (List of columns)

ALTER TABLE tablename Add index (List of columns)

CREATE TABLE TableName ([...], index [indexname] (List of columns)

2. Uniqueness Index: Create unique index

Alter ... add unique

Primary key: A unique index that must be specified as primary key

3, Full-text indexing: from 3.23.23 Version to support Full-text indexing and Full-text search, Fulltext,

Can be created on a column of char, varchar, or text type.

4, single row index, multiple column index:

Multiple single-column indexes have different query effects from a single, multiple-column index because:

When executing a query, MySQL can only use one index, and selects one of the most restrictive indexes from multiple indexes.

5, the leftmost prefix (leftmost prefixing): Multiple-column index, such as: Fname_lname_age index, the following search conditions MySQL will use

Fname_lname_age index: Firstname,lastname,age;firstname,lastname;firstname, other circumstances will not be used.

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.