--データベースの作成 USE [master] GO /****** Object: Database [PartitionDB] Script Date: 08/05/2005 02:57:43 ******/ CREATE DATABASE [PartitionDB] ON PRIMARY ( NAME = N'PartitionDB', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL.2\MSSQL\DATA\PartitionDB.mdf' , SIZE = 3072KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB ), FILEGROUP [PartitionFG1] ( NAME = N'PartitionFG1File', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL.2\MSSQL\DATA\PartitionFG1File.ndf' , SIZE = 3072KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB ), FILEGROUP [PartitionFG2] ( NAME = N'PartitionFG2File', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL.2\MSSQL\DATA\PartitionFG2File.ndf' , SIZE = 3072KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB ), FILEGROUP [PartitionFG3] ( NAME = N'PartitionFG3File', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL.2\MSSQL\DATA\PartitionFG3File.ndf' , SIZE = 3072KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB ), FILEGROUP [PartitionFG4] ( NAME = N'PartitionFG4File', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL.2\MSSQL\DATA\PartitionFG4File.ndf' , SIZE = 3072KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB ) LOG ON ( NAME = N'PartitionDB_log', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL.2\MSSQL\DATA\PartitionDB_log.ldf' , SIZE = 1024KB , MAXSIZE = 2048GB , FILEGROWTH = 10%) COLLATE Japanese_CI_AS GO --アクティブDBの変更 use [PartitionDB] GO --パーティション関数の作成 create partition function PartitionFunc(int) as range left for values(100, 200, 300) go --パーティションスキームの作成 create partition scheme PartitionScheme as partition PartitionFunc To (PartitionFG1, PartitionFG2, PartitionFG3, PartitionFG4) go --パーティションを利用したテーブルとPKインデックスを作成する CREATE TABLE [dbo].[PartitionTable]( [ID] [int] NOT NULL, [VALUE] [nchar](4000) COLLATE Japanese_CI_AS NULL, CONSTRAINT [PK_PartitionTable] PRIMARY KEY CLUSTERED ( [ID] ASC ) ON [PartitionScheme]([ID]) ) ON [PartitionScheme]([ID])