Home > Database > Mysql Tutorial > sql创建表索引 create index()语句

sql创建表索引 create index()语句

不言
Release: 2018-05-17 16:05:07
Original
3623 people have browsed it

sql创建表索引 create index()语句

mssql server 方法
语法:
create [索引类型] index 索引名称
on 表名(列名)
with fillfactor = 填充因子值0~100
go

实例

create nonclustered index ix_test_tname --创建一个非聚集索引
on test(tname)  --为test表的tname字段创建索引
with fillfactor = 30 --填充因子为30%
go
select * from test(index = ix_test_tname) where tname = 'a'
Copy after login

方法

mysql创建索引语法

create [unioun|fulltext|spatial] index indexname[using indextype] on
tablename( tablenamecol)
index_col_name:
col_name[ (length)][asc |desc]
Copy after login

更多详细内容请查看:-

index.htm

实例

create index 实例
本例会创建一个简单的索引,名为 "personindex",在 person 表的 lastname 列

create index personindex
on person (lastname)
Copy after login

如果您希望以降序索引某个列中的值,您可以在列名称之后添加保留字 desc:

create index personindex
on person (lastname desc)
Copy after login

假如您希望索引不止一个列,您可以在括号中列出这些列的名称,用逗号隔开:

create index personindex
on person (lastname, firstname)
Copy after login
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