mysql--Index

Source: Internet
Author: User

First, the simple operation of the index (increase and deletion of the search)

Create an index

CREATE [unique| Fulltext| SPATIAL] INDEX index_name

[USING Index_type]

on table_name (index_col_name,...)

[unique| Fulltext| Spatial]: Represents the type of index created , representing a unique index, a full-text index, and a spatial index, respectively;

[USING Index_type]: Indicates type of index , the index type has a btree index and a hash index.

The storage engine can only use Btree in tables MyISAM and InnoDB;

Btree Index and hash index can be used in tables where the storage engine is memory and heap

Note: Another way to create an index syntax

ALTER TABLE table_nameADD [unique| Fulltext| SPATIAL]INDEX [index_name] [Index_type] (index_col_name,...)

View Index

SHOW INDEX from table_name

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>

Delete Index

- -Deletes the index of the specified name in the specified table

ALTER   Span style= "font-size:12px;font-family: ' Courier New '; Color:rgb (0,0,255); Background-color:rgb (255,255,255);" >table   table_name DROP   INDEX   index_name;

modifying indexes

There is no instruction to modify the index in MySQL, in general, delete the original index directly, re-establish the same name index.

Example: Adding and Deleting indexes: performing add/drop that index on that table

Add index

CREATE UNIQUE Index Index_prizecide on Bsy_prizeinfo (prizecode);

View Index

Show Index from Bsy_prizeinfo;

Delete Index

ALTER TABLE Bsy_prizeinfo DROP Index Index_prizecode

Add index

Alter table bsy_prizeinfo add UNIQUE index index_prizecode (prizecode);

Ii. type of index


mysql--Index

Related Article

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.