Mysql index (8)

Source: Internet
Author: User


Mysql (8) index-related links: Mysql (1) mysql installation http://www.bkjia.com/database/210210/162314.html#mysql( 2) database-related operations (3) actions on Data Tables http://www.bkjia.com/database/201210/162316.html#mysql( 4) Actions on data query operations on Data Tables (5) Actions on time between (6) string mode matching http://www.bk Jia.com/database/201210/162.16.html?mysql( 7) Deep select query http://www.bkjia.com/database/201210/163970.html I. Using Alter statements to create and delete indexes www.2cto.com there are three situations: INDEX: normal INDEX, INDEX columns can contain repeated values. UNIQUE: UNIQUE index, which ensures that the index column does not contain duplicate values. Primary key: it is a UNIQUE index with PRIMARY. This indicates that a table can only contain one primary key.
ALTER tablename add index index_name (column_list) ALTER tablename add unique index_name (column_list) ALTER tablename add primary key index_name (column_list) tablename is the name of the table to be indexed. column_list indicates which columns are indexed. ALTER tablename drop index index_name ALTER tablename drop primary key the first statement can be used to delete any INDEX, and the second statement can only be used to delete an INDEX with PRIMARY. For example, www.2cto.com creates an index for the student table. Alter table student add primary key (id), add index mark (chinese, math, english ); this example shows that a PRIMARY index is created (the column using this index must have a column with the not null attribute) and an index for multiple columns. 2. CREATE/DROP is used to CREATE/delete indexes. create unique index index_name ON tablename (column_list ,...); create index index_name ON tablename (column_list ,...); the meaning is the same as above. Delete An INDEX: drop index index_name ON tablename;

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.