Database optimization tutorial (6) index-related operations, tuning Indexes

Source: Internet
Author: User

Database optimization tutorial (6) index-related operations, tuning Indexes
Iii. Index


3. Index-related operations

In the previous section, we introduced the functions and types of indexes. This section describes the operations related to indexes!

1) Add an index

I have already introduced it. Here I will summarize it.

Add primary key index

[Plain]View plaincopy
  1. Create table aaa
  2. (Id int unsigned primary key auto_increment,
  3. Name varchar (32) not null defaul '');
  4. Alter table name add primary key (column name );

Add Common Index

[Plain]View plaincopy
  1. Create index name on table (column name 1, column name 2 );

Add a unique index

[Plain]View plaincopy
  1. Create table ddd (id int primary key auto_increment, name varchar (32) unique );
  2. Create unique index name on table name (list ..);

Add full-text index

[Plain]View plaincopy
  1. Create table articles (
  2. Id int unsigned AUTO_INCREMENT not null primary key,
  3. Title VARCHAR (200 ),
  4. Body TEXT,
  5. FULLTEXT (title, body)
  6. ) Engine = myisam charset utf8;
  7. Alter table articles add fulltext (title, body );

2) query Indexes

[Plain]View plaincopy
  1. Show index from emp \ G


3) delete an index

[Plain]View plaincopy
  1. Drop index name on table name;

4) modify the index

Delete first, and then create

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.