最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
MySql使用create index创建索引方法
时间:2026-06-05 08:49:54 编辑:袖梨 来源:一聚教程网
MySql使用create index创建索引



1.创建普通索引
-- 列如:创建表book1给表中sno添加普通索引
-- 语法:create index 索引名 on 表名(字段名)
create table book1( id int(8), name varchar(20), price float(3), date varchar(20), sno int(8))create index index_book1 on book1(sno)
2.创建唯一索引
-- 列如:给表book2中name添加唯一索引
-- 语法:create unique index 索引名 on 表名(字段名)
create table book2( id int(8), name varchar(20), price float(3), date varchar(20), sno int(8))create unique index index_book2 on book2(name)
3.创建全文索引 fulltext
-- 列如:创建表book3给表中给sinfo添加全文索引
-- 语法:create fulltext index 索引名 on 表名(字段名)
create table book3( id int(8), name varchar(20), price float(3), date varchar(20), sno int(8), sinfo varchar(200))create fulltext index index_book3 on book3(sinfo)
4.空间索引的创建 spatial
-- 列如:创建表book4给表中给sloc添加空间索引
-- 语法:create spatial index 索引名 on 表名(字段名)
create table book4( id int(8), name varchar(20), price float(3), date varchar(20), sno int(8), sinfo varchar(200), sloc point not null)create spatial index index_book4 on book4(sloc)
5.复合索引
-- 列如:创建表book5给表中给sno和name添加复合索引
-- 语法:create index 索引名 on 表名(字段名1,字段名2)
create table book5( id int(8), name varchar(20), price float(3), date varchar(20), sno int(8), sinfo varchar(200), sloc point not null)create index index_book5 on book5(sno,name)# 查看表中的索引show index from book5
总结
以上为个人经验,希望能给大家一个参考,也希望大家多多支持本站。
您可能感兴趣的文章:- 详解MySQL数据库、表与完整性约束的定义(Create)
- MySQL统计今日生成create_time的数据量的方法小结
- MySQL中的自定义函数(CREATE FUNCTION)
- MySQL建表(create table)命令解读
- 解决Mysql建表时报错invalid ON UPDATE clause for 'create_date' column
- MySQL中CREATE DATABASE语句创建数据库的示例
相关文章
- Claude开发者国内可以用吗?2026年3种接入方案对比 06-12
- 公交APP推荐排行:实用实时覆盖广的好用乘车软件 06-12
- 免费无广告漫画软件推荐:高清流畅看漫画APP合集 06-12
- 手机26键打字练习APP推荐:高效提升中文输入速度的实用软件 06-12
- Apple Watch如何查看心电图 06-12
- 驾校通怎样设置驾校 06-12