Sql Server 课堂代码教案-2018-11-28 索引的创建和应用

根据数据库的用户搜索习惯,创建了3个索引,见下图所示:

Sql Server 课堂代码教案-2018-11-28 索引的创建和应用

这3个索引的应用及Sql编程中的if语句的使用:

--索引的分类:
--1.聚集索引
use cs
go
select *
from ss
where GID='ea0ab5a0-da70-4132-b1aa-15a44d40f050'
go
--2.非聚集索引
use cs
go
select *
from ss
where FlowID=3
go

use cs
go
select *
from ss
where FlowID=3 and Name='eee'
go

--编程
--1
declare @a int,@b int
set @a=1
set @b=2
select @[email protected]
print @[email protected]
go

--2
declare @a int,@b int
select @a=1,@b=2
select @[email protected]
print @[email protected]
go

--3
declare @a int,@b int
select @a=3,@b=2
if(@a>@b)
	print('a>b')
else if(@[email protected])
	print('a==b')
else
	print('a<b')
go