《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. 百科知识 华为手机P7如何更换电池

    参考下面 教程 https://item.jd.com/3265516.html  

  2. C中的预编译编译链接

        http://ke.qq.com/webcourse/index.html#course_id=67888&term_id=100058920&taid=13934591901 ...

  3. Ffmpeg 获取USB Camera 视频流

    本文讲述的案例是如何通过Ffmpeg实现从USB Camera中获取视频流并将视频流保存到MP4文件. 本文亦适用于从USB Camera 获取视频流并将视频流转发到rtmp服务的案例,二者基本的原理 ...

  4. MySQL提示Access denied for user &#39;&#39;@&#39;localhost&#39;”的解决

    记得那时由于没有网络,把rootpassword改错了写成了: update user set password="122" where user="root" ...

  5. caffe学习--cifar10学习-ubuntu16.04-gtx650tiboost--1g--01

    引用了下文的资料,在此感谢! http://www.cnblogs.com/alexcai/p/5468164.html http://blog.csdn.net/garfielder007/arti ...

  6. PHP框架的基本原理以及选择标准

    PHP框架的原理 说到PHP框架,可能很多PHP新手会感到有些胆怯.其实,PHP框架也不是那么深不可测的,框架就是别人使用PHP基础只是为你写好了的东西,只是封装在一起:这就好比我们使用PHP的函数, ...

  7. ReentrantLock和Synchronized

    1 synchronized 1.1 一旦没有获取到就只能一直等待 A和B都获取同一个对象锁,如果A获取了,B没有获取到,那么在A释放该锁之前,B只能无穷等待下去. 1.2 synchronized是 ...

  8. types of transfrmations

    http://math.wallawalla.edu/~duncjo/courses/math113/winter08/notes/9-1_math113.pdf Name What Changes ...

  9. C++笔记之外部类访问内部类的私有成员

    如下图所示 内部类可以访问外部类的私有成员 而外部类无法访问内部类的私有成员 为了能让外部类访问内部类的私有成员,将外部类声明为内部类的友元类即可 #include <iostream> ...

  10. C++ Lambda表达式和仿函数笔记

    C++11中引入了Lambda表达式,其语法如下: [capture list](parameter list)->return type { function body } 参考博文:C++ ...