《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. 【Python】输出程序运行的百分比

    对于一些大型的Python程序.我们须要在命令行输出其百分比,显得更加友好,以免被人误会程序陷入死循环.假死的窗口. 关键是利用到不换行的输出符\r,\r的输出.将直接覆盖掉此行的内容. 比方例如以下 ...

  2. php.ini的载入位置

    php.ini文件找不到,载入WINDOS下的,但找不到,后来强制-c查找是OK的.思考,为什么载入window下的ini文件.1.可能是有一个默认路径.2.可能没有路径.默认载入. 问题解决:htt ...

  3. Golang Map Addressability

    http://wangzhezhe.github.io/blog/2016/01/22/golangmapaddressability-dot-md/ 在golang中关于map可达性的问题(addr ...

  4. HDU ACM 1073 Online Judge -&gt;字符串水题

    分析:水题. #include<iostream> using namespace std; #define N 5050 char a[N],b[N],tmp[N]; void Read ...

  5. caffe2--ubuntu16.04--14.04--install

    Install Welcome to Caffe2! Get started with deep learning today by following the step by step guide ...

  6. Dash 使用

    花了 160 买了这个软件,至少看一遍它的 user guide,钱不能白花. https://kapeli.com/guide/guide.html 设置全局快捷键 Preference -> ...

  7. 08 comet反向ajax

    一:HTTP协议与技久链接+分块传输---->反向ajax 反向ajax又叫comet, server push,服务器推技术. 应用范围: 网页聊天服务器,, 新浪微博在线聊天,google ...

  8. android handler looper

    http://www.cnblogs.com/plokmju/p/android_Handler.html

  9. ComboBox在WPF中的绑定示例:绑定项、集合、转换,及其源代码

    示例1.Selector(基类) 的示例Controls/SelectionControl/SelectorDemo.xaml <Page x:Class="Windows10.Con ...

  10. iOS中从零開始使用protobuf

    让我们一起打开以下这个链接 https://github.com/alexeyxo/protobuf-objc 在github上有protobuf-objc,当中的readme能够教会我们安装prot ...