阅读更多
--表分区
create table splitTable(id int primary key identity, name varchar(100),descript varchar(300),createTime datetime);
insert into splitTable(name, descript,createTime) values('分区表测试','分区表测试测试','2017-01-12');
insert into splitTable select name,descript,createTime from splitTable;
select * from splitTable;
create partition function testPartition(Datetime) as range right for values('2017-01-09', '2017-01-11');
select * from sys.filegroups;
select * from sys.partition_functions
create partition scheme testPartition_scheme as partition testPartition
to ([FileGroup1],[Primary],[FileGroup2]);
CREATE NONCLUSTERED INDEX [sniperTable_Index_new] ON [dbo].[splitTable]
(
createTime ASC
)WITH (SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF) ON [testPartition_scheme]([createTime])
GO
select from splitTable where $PARTITION.testPartition(createTime)=3
truncate table splitTable;