MySQL 创建索引(Create Index)的方法和语法结构及例子
程序员文章站
2023-11-26 19:19:46
create index syntax create [unique|fulltext|spatial] index index_name [index_type] on...
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}
-- 创建无索引的表格
create table testnopk (
id int not null,
name varchar(10)
);
-- 创建普通索引
create index idx_testnopk_name on testnopk (name);
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}
复制代码 代码如下:
-- 创建无索引的表格
create table testnopk (
id int not null,
name varchar(10)
);
-- 创建普通索引
create index idx_testnopk_name on testnopk (name);