Partition Table in Sql Server
In this tutorial i will let you know that how to create a partition table in sql server.Partitioning makes large tables or indexes more manageable, because partitioning enables you to manage and access subsets of data quickly and efficiently.
Partitioned tables and indexes are only supported in the SQL Server Enterprise and Developer editions.
Steps To create Partition table In Sql server:-
- Create a partition function.
- Create a partition scheme.
- Now Create the table and store data in it.
Query to create the partition function:-
create partition function pf(int) as range left for values(10,9,8,7,6,5)
Query to create the partition scheme:-
create partition scheme ps as partition pf to (a,b,c,d,e,f,g)
Query to create table:-
create table partable(id int,name varchar(50),class varchar(20))
Insert Dummy Data into table:-
insert into partable values(9,'jai','twelve') insert into partable values(1,'om','fifth') insert into partable values(2,'bharat','third') insert into partable values(8,'ravi','fifth') insert into partable values(9,'aman','tenth') insert into partable values(10,'ankur','fifth') insert into partable values(6,'ashvani','ninth') insert into partable values(7,'jaiveen','fifth') insert into partable values(9,'john','ninth') insert into partable values(1,'marry','fifth') insert into partable values(2,'lucy','twelve') insert into partable values(3,'diana','fifth') insert into partable values(4,'gerry','fifth') insert into partable values(5,'partablei','third') insert into partable values(6,'charan','fifth') insert into partable values(7,'george','tenth')
Now see your data is stored in which filegroup:-
select *, $partition.pf(id) as "partition Number" from partable