Database Reference
In-Depth Information
create table dbo.OrdersPT
(
OrderId int not null,
OrderDate datetime2(0) not null,
OrderNum varchar(32) not null,
OrderTotal money not null,
CustomerId int not null,
/* Other Columns */
);
create unique clustered index IDX_OrdersPT_OrderDate_OrderId
on dbo.OrdersPT(OrderDate, OrderId)
with
(
data_compression = page on partitions(1 to 28),
data_compression = row on partitions(29 to 31)
)
on psOrders(OrderDate);
create nonclustered index IDX_OrdersPT_CustomerId
on dbo.OrdersPT(CustomerId)
with
(
data_compression = page on partitions(1 to 28),
data_compression = row on partitions(29 to 31)
)
on psOrders(OrderDate);
You control how boundary values are stored by specifying either the
RANGE LEFT
or
RANGE RIGHT
parameter of
the partition function. In our example, we are using the
RANGE RIGHT
parameter, which indicates that the boundary
value is stored on the right partition. With this option, if 2012-02-01 is the first boundary value, the leftmost partition
stores the data, which is prior to that date. All values, which are equal to the boundary value, are stored in the second
from the left partition. Alternatively, if we used the
RANGE LEFT
parameter, the boundary value data would be stored in
the left partition.
Figure
15-1
shows the physical data layout of the
OrdersPT
table.