日期:2014-05-17 浏览次数:20532 次
create table table1
(
id int,
Name varchar(50),
Remark varchar(200),
CreateDate datetime
)
--在时间字段上创建聚集索引创建索引
create clustered index index_createdate on table1(createDate desc)
--在id字段上创建非聚集索引
create unique index index_id on table1(Id desc)
select * from table1 where id ='1234'
--SELECT * FROM [table1] WHERE [id]=@1
|--Nested Loops(Inner Join, OUTER REFERENCES:([dbtest1].[dbo].[table1].[CreateDate]))
|--Index Seek(OBJECT:([dbtest1].[dbo].[table1].[index_1]), SEEK:([dbtest1].[dbo].[table1].[id]=(1234)) ORDERED FORWARD)
|--Clustered Index Seek(OBJECT:([dbtest1].[dbo].[table1].[index_createdate]), SEEK:([dbtest1].[dbo].[table1].[CreateDate]=[dbtest1].[dbo].[table1].[CreateDate]) LOOKUP ORDERED FORWARD)
--而oracle中就不一样了,类似的表,是一个索引组织表(相当于id上的聚集索引),根据普通索引来查询
--一样是普通索引找到聚集索引,然后直接出来结果了,看截图
create table indexTable(
ID int,
NAME varchar2 ( 50 ),
CreateDate date,
Remark varchar2(50),
constraint pk_id primary key ( ID )
)
organization index;