首页 > 数据库技术 > 详细

learn about sqlserver partitition and partition table --- add or remove table partitions addition more

时间:2020-02-16 20:00:06      阅读:76      评论:0      收藏:0      [点我收藏+]

Yes . In the previous. chapter , we see how to generate "partition function" "parttiton schema" and "parttiton table"

what can we do if we need to add or drop an table partition ?

Here is exist status:

/* add partition (oracle)== split partition (oracle,mssql) */
/* drop parttiton (oracle) == merge partition (mssql) */

技术分享图片

 

 and

技术分享图片

 

 

Here we go

/* add partitions */

alter database test add filegroup TESTFG_201602;
alter database test add file (name = TESTFG_201602,filename = "C:\var\opt\mssql\data\TESTFG_201602.ndf",size = 1MB,maxsize = unlimited,filegrowth = 1MB) to filegroup TESTFG_201602;
go
alter partition scheme PS_DATETIME_M_TEST NEXT USED TESTFG_201601;
alter partition function PF_DATETIME_M_TEST() split range ( N‘2016-01-02T00:00:00.000‘);
go

That script has an error. you would see if I execute it

技术分享图片

 

 However,  It is right about "less than", because we use range right    --- it will be talk about it in detail

 

技术分享图片

 

 

Let get into bussiness, hot to fix that ?

Yes, we merge it

/* drop partitions */
alter partition function PF_DATETIME_M_TEST() merge range (N‘2016-01-02T00:00:00.000‘);
--alter database test remove file TESTFG_201602;
--alter database test remove filegroup TESTFG_201602;

then we can see that return

技术分享图片

 

 

and we can make it right

alter partition scheme PS_DATETIME_M_TEST NEXT USED TESTFG_201602;
alter partition function PF_DATETIME_M_TEST() split range ( N‘2016-02-01T00:00:00.000‘);
go

Yes. we did it

技术分享图片

 

learn about sqlserver partitition and partition table --- add or remove table partitions addition more

原文:https://www.cnblogs.com/partition-liu/p/12317942.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!