索引
使用索引可以加快查询速度
索引的原则
数据量很大,且经常被查询的数据表可以设置索引
索引只添加在经常被作为检索条件的字段上面
不要在大字段上创建索引,字符串过长不适合添加索引
use test;
#创建索引
create table t_message (
id int unsigned primary key,
content varchar(200) not null,
type ENUM("公告","通报","个人通知") not null,
create_time timestamp not null,
index idx_type (type)
)character set = utf8;
#删除索引
drop index idx_type on t_message;
#添加索引
create index idx_type on t_message(type);
alter table t_message add index idx_type(type);
#查看索引信息
show index from t_message;
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 零经验选手,Compose 一天开发一款小游戏!
· 一起来玩mcp_server_sqlite,让AI帮你做增删改查!!