| jose's profileSQL Server 2005 blogsBlogLists | Help |
|
February 28 Introduction to Table PartitioningIntroduction to Table Partitioning In SQL Server 2005 Table partitioning is one of Scalability and maintainability features of SQL Server 2005. With these feature a table can be spread across multiple filegroups. It also allows maintenance (such backup and restore) operations to be performed only on subsets of data (partition) rather than the whole table. Some partitions in a table can be mapped to a read-only filegroup while other partitions can be mapped to a read/write enabled filegroups.These feature can be used as security implementation to protect subset of sensitive data residing in the same table. Consider a case of a Sales transaction table which contains sales transaction from the present and previous years. Those transactions from the previous years (partition) can be mapped to a readonly filegroup while the present sales transaction can be mapped on a read/write filegroups thereby protecting previous records from being altered irregardless of whoever has logged-in to the system provided he/she did not modify the filegroups readonly attribute Although the data can be spread across multiple files and filegroups it is still treated as a single table in the datbase
Requirements for table partitioning:
These are the required steps for creating a partitioned table or partitioned index:
To do: A. Creating a partition function 1. Create a new database
2. Create the new partition
B. Creating A partition scheme The partition function above partitions a table bind to it in to 4 partitions as stated above. So a partition scheme for this partition function can be mapped into four different filegroups. For more information about files and filesgroups kindly consult your books online. Here’s a sample TSQL statement for creating a partition scheme
AS PARTITION myRangePF1 TO (test1fg, test2fg, test3fg, test4fg) <-- these are the filegroups In this exercise since we created a database with only one file group which is the "primary" filegroup We will be using the this scripts.
AS PARTITION myRangePF1 TO ( ‘primary’, ‘primary’, ‘primary’, ‘primary’)To do: "mytest" database from the previous exrcise 4. click on the new query paste the scripts above and press F5 to execute You have just created a new partitioning scheme. 5. Drop the partition scheme and recreate it by using the following scripts below. Notice that there is an excess filegroup in the filegroup names Create PARTITION SCHEME myRangePS1 AS PARTITION myRangePF1 TO ( ‘primary’, ‘primary’, ‘primary’, ‘primary’, ‘primary’)6. SQL server creates the partition scheme and returns the following message: Partition scheme 'myRangePS1' has been created successfully. 'PRIMARY' is marked as the next used filegroup in partition scheme 'myRangePS1'. As you can see the excess filegroup has been mark for use should a new partition would be created in the future C. Create a table that uses the partition Use the following scripts to create a partion table
ON myRangePS1 (col1) ; |
|
|