有几个关于分区的问题
有几个关于分区的问题,希望大家帮忙了1. 表已经存在,能否再应运分区方案呢,如果可以,这么用?
2. sqlserver里能否直接通过执行Select * into 表 from 表2时,也带上分区方案,如果能这样那是方便不过?
可以
1:刪除普通索引
2:刪除主健索引並轉為分區表
3:再恢復主健索引
4:恢復普通索引
use TEMPDB
go
create table t(ID int identity ,Num int not null constraint PK_T primary key(Num,ID))
create index IX_T_Num on T(Num)
go
create partition function F_Partition(int)
as range right for values(1,100,1000)
go
CREATE PARTITION SCHEME P_schema
as partition F_Partition ALL to ([PRIMARY])
go
drop index IX_T_Num on T
alter table T drop constraint PK_T with(Move to P_schema(Num))
alter table t alter column ID int not null
alter table T add constraint PK_T primary key (Num,ID)
select * from T
DROP TABLE T
DROP PARTITION SCHEME P_schema DROP partition function F_Partition
-----------------------------
如果主健只有一列時直接改
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->use TEMPDBgocreate table t(ID int identity constraint PK_T primary key,Num int not null )--只有一個IDcreate index IX_T_Num on T(Num)gocreate partition function F_Partition(int)as range right for values(1,100,1000)goCREATE PARTITION SCHEMEP_schemaas partition F_PartitionALL to ([PRIMARY])godrop index IX_T_Num on Talter table T drop constraint PK_T with(Move to P_schema(ID))--這里改為IDalter table t alter column ID intnot nullalter table T add constraint PK_T primary key (ID)--改為IDselect * from TDROP TABLE TDROPPARTITION SCHEMEP_schemaDROP partition functionF_Partition
页:
[1]