《Windows Azure Platform 系列文章目录

  昨天客户正好提到这个问题,现在记录一下。

  我们在使用传统的SQL Server,会使用Table Partition,这个功能在云端的Azure SQL Database也是可以实现的。

  

  1.首先我们创建一个Azure SQL Database数据库,过程略

  2.使用SQL Server Management Studio链接

  3.执行下面的TSQL

--Create Table
CREATE TABLE [dbo].[FactInternetSales]
(
[ProductKey] int NULL
, [OrderDateKey] int NULL
, [CustomerKey] int NULL
, [PromotionKey] int NULL
, [SalesOrderNumber] nvarchar(20) NULL
, [OrderQuantity] smallint NULL
, [UnitPrice] money NULL
, [SalesAmount] money NULL
) --CREATE Partition Function
CREATE PARTITION FUNCTION [pf_DayOfTheYear](INT) AS RANGE LEFT FOR VALUES
(20000101,20010101,20020101
,20030101,20040101,20050101
) --Creating a SQL Partition Scheme
CREATE PARTITION SCHEME [ps_DayOfTheYear] AS PARTITION [pf_DayOfTheYear] ALL TO ([PRIMARY]) --Show Partition
SELECT ps.name, pf.name, boundary_id, [value]
FROM sys.partition_schemes ps
INNER JOIN sys.partition_functions pf ON pf.function_id=ps.function_id
INNER JOIN sys.partition_range_values prf ON pf.function_id=prf.function_id --Create Patition
CREATE CLUSTERED INDEX IX_TABLE1_OrderdateKey ON dbo.[FactInternetSales] (OrderDateKey)
WITH (STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF,
ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
ON [ps_DayOfTheYear](OrderDateKey)
GO --Test Data
INSERT INTO [dbo].[FactInternetSales](OrderDateKey) VALUES (20000101);
--多增加一行
INSERT INTO [dbo].[FactInternetSales](OrderDateKey) VALUES (20000101); INSERT INTO [dbo].[FactInternetSales](OrderDateKey) VALUES (20010101);
INSERT INTO [dbo].[FactInternetSales](OrderDateKey) VALUES (20020101);
INSERT INTO [dbo].[FactInternetSales](OrderDateKey) VALUES (20030101);
INSERT INTO [dbo].[FactInternetSales](OrderDateKey) VALUES (20040101);
INSERT INTO [dbo].[FactInternetSales](OrderDateKey) VALUES (20050101); -------------------------------- SHOW INDEXES with their partitions / row counts (only one to begin with) ------------------------------------------------------------------------
SELECT o.name objectname, i.name indexname, partition_id, partition_number, [rows] --, f.[name] 'FileGroup', i.data_space_id
FROM sys.partitions p
INNER JOIN sys.objects o ON o.object_id=p.object_id
INNER JOIN sys.indexes i ON i.object_id=p.object_id and p.index_id=i.index_id
--left outer join sys.filegroups f on i.data_space_id = f.data_space_id
WHERE o.name = 'FactInternetSales'

Azure SQL Database (27) 创建Table Partition的更多相关文章

  1. Azure SQL Database (25) Azure SQL Database创建只读用户

    <Windows Azure Platform 系列文章目录> 本文将介绍如何在Azure SQL Database创建只读用户. 请先按照笔者之前的文章:Azure SQL Databa ...

  2. Azure SQL Database (24) 使用新管理界面,创建跨数据中心标准地域复制(Standard Geo-Replication)

    <Windows Azure Platform 系列文章目录> 文本是对:SQL Azure (17) SQL Azure V12 - 跨数据中心标准地域复制(Standard Geo-R ...

  3. Azure Sql Database为某个数据库创建单独的访问账户

    由于SQL Management Studio对Azure SQL Database支持不完美,不能使用图形界面,因此配置数据库就会有不同的麻烦,下面是本人配置访问账户的一些经验: 1.以管理员登陆之 ...

  4. Azure SQL Database (19) Stretch Database 概览

    <Windows Azure Platform 系列文章目录>  Azure SQL Database (19) Stretch Database 概览      Azure SQL Da ...

  5. Azure SQL Database (21) 将整张表都迁移到Azure Stretch Database里

    <Windows Azure Platform 系列文章目录>  Azure SQL Database (19) Stretch Database 概览      Azure SQL Da ...

  6. Azure SQL Database (22) 迁移部分数据到Azure Stretch Database

    <Windows Azure Platform 系列文章目录>  Azure SQL Database (19) Stretch Database 概览      Azure SQL Da ...

  7. Java连接Azure SQL Database

    Azure SQL Database是Azure上的数据库PAAS服务,让用户可以快速的创建和使用SQL数据库而不用担心底层的备份,安全,运维,恢复等繁琐的工作,本文简单介绍如何使用Java程序连接到 ...

  8. Azure SQL Database (23) Azure SQL Database Dynamic Data Masking动态数据掩码

    <Windows Azure Platform 系列文章目录> 我们在使用关系型数据的时候,有时候希望: - 管理员admin,可以查看到所有的数据 - 普通用户,某些敏感字段,比如信用卡 ...

  9. Azure SQL Database (22) Azure SQL Database支持中文值

    <Windows Azure Platform 系列文章目录> 在笔者之前的文章里,已经介绍了如何使Azure SQL Database支持中文: SQL Azure(七) 在SQL Az ...

随机推荐

  1. [Algorithms] Tree Data Structure in JavaScript

    In a tree, nodes have a single parent node and may have many children nodes. They never have more th ...

  2. 前端学习——使用Ajax方式POST JSON数据包

    0.前言     本文解释怎样使用Jquery中的ajax方法传递JSON数据包,传递的方法使用POST(当然PUT又有时也是一个不错的选择).POST JSON数据包相比标准的POST格式可读性更好 ...

  3. Kristen Grauman

    http://www.cs.utexas.edu/~grauman/ CV         Publications         Code           Data        Short ...

  4. Scrapy爬虫入门系列2 示例教程

    本来想爬下http://www.alexa.com/topsites/countries/CN 总排名的,但是收费了 只爬了50条数据: response.xpath('//div[@class=&q ...

  5. 继续聊WPF——获取ComboBox中绑定的值

    千万不要认为WPF中的数据绑定会很复杂,尽管它的确比Winform程序灵活多了,但其本质是不变的,特别是ComboBox控件,我们知道在Winform中对该控件的有两个专为数据绑定而设定的属性——Di ...

  6. jquery设置多个css样式

    $(selector).css({property:value, property:value, ...}) 实例: $("p").css({ "color": ...

  7. js中变量的声明

    大家都知道js中变量的声明是要提前的,下面有4个样例: 1.if(!"t" in window){  var t = 1; }       alert(t);答案是undefine ...

  8. ElasticSearch(八)关于document的一些知识点

    先查看一条数据: GET /ecommerce/product/5 { "_index" : "ecommerce", "_type" : ...

  9. How to deploy a Delphi OSX project from the command line

    Delphi has a well developed command line build process (via MSBuild) for Windows projects. After the ...

  10. php高级技巧总结

    通过对<深入理解PHP:高级技巧.面向对象与核心技术>这本书的学习,总结出常用的php高级技巧,也方便自己以后查阅;我认为该书是php高级教程的葵花宝典,哈哈.里面的内容很实用,尤其是在项 ...