当前位置:网站首页>数据库-索引
数据库-索引
2022-06-27 05:33:00 【zhixingheyi_tian】
创建索引
索引被创建于已有的表中,它可使对行的定位更快速更有效。可以在表格的一个或者多个列上创建索引,每个索引都会被起个名字。用户无法看到索引,它们只能被用来加速查询。
注释:更新一个包含索引的表需要比更新一个没有索引的表更多的时间,这是由于索引本身也需要更新。因此,理想的做法是仅仅在常常用于搜索的列上面创建索引。
唯一的索引 (Unique Index)
在表格上面创建某个一个唯一的索引。唯一的索引意味着两个行不能拥有相同的索引值。
CREATE UNIQUE INDEX 索引名称
ON 表名称 (列名称)
“列名称” 规定你需要索引的列。
索引
简单的索引
在表上创建一个简单的索引。当我们省略关键词 UNIQUE 时,就可以使用重复的值。
CREATE INDEX 索引名称
ON 表名称 (列名称)
“列名称” 规定你需要索引的列。
实例
本例会创建一个简单的索引,名为 “PersonIndex”,在 Person 表的 LastName 字段:
CREATE INDEX PersonIndex
ON Person (LastName)
如果您希望以降序索引某个列中的值,您可以在列名称之后添加保留字 DESC:
CREATE INDEX PersonIndex
ON Person (LastName DESC)
假如您希望索引不止一个列,您可以在括号中列出这些列的名称,用逗号隔开:
CREATE INDEX PersonIndex
ON Person (LastName, FirstName)
边栏推荐
- 代码即数据
- Discussion on streaming media protocol (MPEG2-TS, RTSP, RTP, RTCP, SDP, RTMP, HLS, HDS, HSS, mpeg-dash)
- 论文解读(LG2AR)《Learning Graph Augmentations to Learn Graph Representations》
- When STM32 turns off PWM output, it is a method to fix IO output at high or low level.
- Using domain name forwarding mqtt protocol, pit avoidance Guide
- Codeforces Round #802 (Div. 2)
- The most detailed download tutorial of MySQL
- Pycharm 中 Terminal 无法进入 venv 环境的问题
- 洛谷P2939 [USACO09FEB]Revamping Trails G 题解
- STM32关闭PWM输出时,让IO输出固定高或低电平的方法。
猜你喜欢

Experience oceanbase database under win10

双位置继电器XJLS-8G/220

流媒体协议初探(MPEG2-TS、RTSP、RTP、RTCP、SDP、RTMP、HLS、HDS、HSS、MPEG-DASH)

Double position relay rxmd2-1mrk001984 dc220v

Leetcode99 week race record

leetcode298周赛记录

Microservice system design -- unified authentication service design

Niuke practice 101-c reasoning clown - bit operation + thinking

双位置继电器RXMVB2 R251 204 110DC

Gao Xiang slam14 lecture - note 1
随机推荐
LeetCode-515. Find the maximum value in each tree row
neo4j community与neo4j desktop冲突
Gao Xiang slam14 lecture - note 1
Redis高可用集群(哨兵、集群)
Execution rules of pytest framework
022 basics of C language: C memory management and C command line parameters
Two position relay hjws-9440
洛谷P4683 [IOI2008] Type Printer 题解
Tsinghua University open source software mirror website
牛客练习赛101-C 推理小丑---位运算+思维
DAST black box vulnerability scanner part 6: operation (final)
[C language] keyword supplement
清华大学开源软件镜像站网址
流媒体协议初探(MPEG2-TS、RTSP、RTP、RTCP、SDP、RTMP、HLS、HDS、HSS、MPEG-DASH)
Asp. Net core6 websocket simple case
快速排序(非遞歸)和歸並排序
019 basics of C language: C preprocessing
Wechat applet refreshes the current page
洛谷P2939 [USACO09FEB]Revamping Trails G 题解
Neo4j community conflicts with neo4j desktop