MySQL creates an example of index

Source: Internet
Author: User
Tags command line create index mysql table name mysql command line

Environment: MySQL Sever 5.1 + MySQL command line tool

Problem: Creating an Index

CREATE INDEX Syntax:

CREATE [unique| Fulltext| SPATIAL] INDEX index_name

[Index_type]

On Tbl_name (Index_col_name,...)

[Index_type]

Index_col_name:

col_name [(length)] [asc| DESC]

Index_type:

USING {btree | HASH | Rtree}

Example:

--Create TABLE creation table Testindex with no indexes  
(   
  ID int not NULL PRIMARY key   
  , name varchar   
 );   
       
--Create INDEX   
 idx_test_testindex _name on Testindex (Name);

Description: The name of the index is best used in this way: Idx_databasename_tablename_columnname (IDX for index, databaseName for database name, tablename for table name, ColumnName represents the name of the field, if the concept of the database does not exist under Oracle, instead of the table space, the databasename is replaced with the user name.

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/database/MySQL/

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.