MySQL Usage-Simple index

Source: Internet
Author: User

Record some of MySQL's database syntax

1 Change root password: mysqladmin-u root  password ' 123456
1 mysql-  u user name-p password go in MySQL monitor
1 , show databases; show all database names 2 11, CREATE database;
1 CREATE all privileges on test.* to [email protected] identified by ' 123456 '; --Grant all database permissions to the user
1 1, show tables  -- Show all table names in the library 2 2, DESC table name--Show Table structure
1 CREATE TABLE tbl_mobile_wblist (2ID INT PRIMARY KEY auto_increment not NULL COMMENT ' ID ',3Whitemobile VARCHAR (+) DEFAULT NULL COMMENT ' White list phone number ',4Wenabled CHAR (4) DEFAULT ' 1 ' COMMENT ' Enable identity 1: Enable 0: Off ',5Blackmobile VARCHAR (+) DEFAULT NULL COMMENT ' blacklist phone number ',6Benabled CHAR (4) DEFAULT ' 1 ' COMMENT ' Enable identity 1: Enable 0: Off ',7Back VARCHAR (max) DEFAULT NULL COMMENT ' alternate field ',8Up VARCHAR (+) DEFAULT NULL COMMENT ' alternate field '9);
1 CREATE INDEX wb_index on Tbl_mobile_wblist (whitemobile); --Index creation
SHOW INDEX from Tbl_mobile_wblist; --show the index of the table

The first index is the index that is generated when the primary key is created, also known as the primary key index, and a clustered index

1 DROP INDEX wb_test on tbl_mobile_wblist; --Index deletion
1 EXPLAIN SELECT w.whitemobile from Tbl_mobile_wblist W; --View the usage of the index

1 CREATE INDEX we_test_duo on Tbl_mobile_wblist (whitemobile,blackmobile); -- Creating a composite index 2 is equivalent to creating an index for each column

1 EXPLAIN SELECT * from tbl_mobile_wblist c WHERE c.blackmobile= ' 123 ';

when the latter column of the composite index is used as a where condition, the index is not taken

MySQL Usage-Simple index

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.