易截截图软件、单文件、免安装、纯绿色、仅160KB

SQL Server 2005 分区表实践——分区切换


本文演示了 SQL Server 2005 分区表分区切换的三种形式:
1. 切换分区表的一个分区到普通数据表中:Partition to Table;
2. 切换普通表数据到分区表的一个分区中:Table to Partition;
3. 切换分区表的分区到另一分区表:Partition to Partition。
并指出了在分区表分区切换过程中的注意事项。
-- 创建分区函数
create partition function PF_Orders_OrderDateRange(datetime)
as
range right for values (
'1997-01-01',
'1998-01-01',
'1999-01-01'
)
go
-- 创建分区方案
create partition scheme PS_Orders
as
partition PF_Orders_OrderDateRange
to ([primary], [primary], [primary], [primary])
go
-- 创建分区表
create table dbo.Orders
(
OrderID int not null
,CustomerID varchar(10) not null
,EmployeeID int not null
,OrderDate datetime not null
)
on PS_Orders(OrderDate)
go
-- 创建聚集分区索引
create clustered index IXC_Orders_OrderDate on dbo.Orders(OrderDate)
go
-- 为分区表设置主键
alter table dbo.Orders add constraint PK_Orders
primary key (OrderID, CustomerID, OrderDate)
go
-- 导入数据到分区表
insert into dbo.Orders
select OrderID, CustomerID, EmployeeID, OrderDate
from dbo.Orders_from_SQL2000_Northwind --(注:数据来源于 SQL Server 2000 示例数据库)
go
-- 查看分区表每个分区的数据分布情况
select partition = $partition.PF_Orders_OrderDateRange(OrderDate)
,rows = count(*)
,minval = min(OrderDate)
,maxval = max(OrderDate)
from dbo.Orders
group by $partition.PF_Orders_OrderDateRange(OrderDate)
order by partition
go
一、切换分区表的一个分区到普通数据表中:Partition to Table
首先建立普通数据表 Orders_1998,该表用来存放订单日期为 1998 年的所有数据。
create table dbo.Orders_1998
(
OrderID int not null
,CustomerID varchar(10) not null
,EmployeeID int not null
,OrderDate datetime not null
) on [primary]
go
create clustered index IXC_Orders1998_OrderDate on dbo.Orders_1998(OrderDate)
go
alter table dbo.Orders_1998 add constrai


相关文档:

SQL要求CDKEY的解决办法

 
[可用]如果出现安装sql server 2000要求CD-KEY的情况,请使用regedt32找开注册表,在以下主键[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager]中建立一个DWORD键
SafeDLLSearchMode并设值为0
这个试过,是可以用的
 
H6TWQ-TQQM8-HXJYG-D69F7-R84VM      - ......

Oracle与SQL Server数据互用性(3)

 作者 Haidong Ji  翻译 GoodKid
在我的关于Oracle和SQL Server 互用性的系列文章 part 1 和 part 2 当中,我讨论了Oracle和SQL Server 的一些不同点的话题以及Oracle驱动的可选性。在本主题中,我将讨论一个来自Oracle 10g的新工具,Oracle即时客户端。
对于Oracle 10g以前的版本,如果想建立和Oracle的连接, ......

MS SQL Server 2008分布式查询MySQL

  近日,俺通过MS SQL Server 2008的链接服务器查询MySQL的数据。其实,俺在多年前就使用过这个,当时是分布式查询Excel表数据,现在,换成异构数据库MySQL。俺以64位系统说明:
   首先,Windows程序访问MySQL数据库需要驱动程序,可以到官方网站下载,俺就是使用Mysql ODBC 5.1 Driver for 64bit,通过数 ......

用ADO管理SQL SERVER !

      在软件开发中,常常需要为程序建立Sql Server数据库的运行环境。完成如在SQL Server数据库中建立设备,建立数据库,建立表格,分配权限等功能,如何方便的建立应用程序所需Sql Server环境的数据库环境,而不用启动SQL Enterprise Manager呢?
下面来看: 
  启动VB6.0,新建一个工 ......

SQL数据库服务器的安全策略 保护数据安全

 SQL Server 2000的安全配置在进行SQL Server 2000数据库的安全配置之前,首先必须对操作系统进行安全配置,保证操作系统处于安全状态。然后对要使用的操作数据库软件(程序)进行必要的安全审核,比如对ASP、PHP等脚本,这是很多基于数据库的Web应用常出现的安全隐患,对于脚本主要是一个过滤问题,需要过滤一些类似&ld ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号