Home > Database > Mysql Tutorial > mysql创建单个和联合索引_MySQL

mysql创建单个和联合索引_MySQL

WBOY
Release: 2016-06-01 13:18:53
Original
1470 people have browsed it

bitsCN.com

首先创建一个表:create table t1 (id int primary key,username varchar(20),password varchar(20));

创建单个索引的语法:create index 索引名 on 表名(字段名)

索引名一般是:表名_字段名

给id创建索引:create index t1_id on t1(id);

创建联合索引的语法:create index 索引名 on 表名(字段名1,字段名2)

给username和password创建联合索引:create index t1_username_password on t1(username,password)

bitsCN.com
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template