MySQL Learning summary----Index
=================================================================================
First, the index
=================================================================================
=================================================================================
Ii. Creating and viewing indexes
=================================================================================
Creating and viewing indexes includes:
1) Create and view normal indexes
2) Create and view unique indexes
3) Create and view full-text indexes
4) Create and view multi-column indexes
A) Create and view normal indexes
Creating and viewing normal indexes is divided into:
1) Creating a table is to create a normal index
2) Create a normal index on a table that already exists
3) Create a normal index from the SQL statement ALTER TABLE
(i), creating a normal index when creating a table
CREATE TABLE Table name (
Property name Data type,
Property name Data type,
Property name Data type,
Index|key "Index Name" (Property name 1 "(length)" "Asc|desc")
);
Note: ASC indicates ascending, desc is descending; Index and key are used to create an index.
1. Create a table named Test in the database Doublelinux and add a normal index
Mysql> CREATE TABLE Test (
AAA int,
BBB varchar (20),
--CCC varchar (20),
-Index INDEX_AAA (AAA)
);
(ii) Create a normal index on a table that already exists
Create index index name on table name (property name "(length)" "Asc|desc")
1. Create an index named INDEX_CCC in table test01 under Database Doublelinux
Mysql> CREATE TABLE test01 (
zzz int,
-xxx varchar (20),
CCC int
);
Query OK, 0 rows affected (0.09 sec)
Mysql> CREATE index INDEX_CCC on test01 (CCC);
Query OK, 0 rows affected (0.11 sec)
records:0 duplicates:0 warnings:0
(iii),
II) Create and view unique indexes
III) Create and view full-text indexes
IV) Create and view multi-column indexes
=================================================================================
Third, delete the index
=================================================================================
This article from "Doublelinux" blog, declined reprint!
MySQL Learning summary----Index