MSSQL2008分割槽表

2021-09-21 12:09:23 字數 2148 閱讀 1430

概念就不多說了,網上大把.  

--分割槽函式的作用是告訴sql server,如何將資料進行分割槽,例如按時間,按年齡,按省.

--而分割槽方案的作用則是告訴sql server,將已分割槽的資料放在哪個檔案組中. 多個硬碟上分開選擇的檔案組更好. 

一,用語句

建立,分割槽方案:

create

partition scheme yearcustomerfollow 

aspartition  

yearcustomerfollowfunction to

([primary

],[primary

],[primary

],[primary

],[primary

])  建立,分割槽函式:

create

partition 

function

yearcustomerfollowfunction(datetime) 

asrange 

right

forvalues

('20100101'

,'20110101'

,'20120101'

,'20130101'

)   刪除乙個分割槽:

alter partition 

function

yearcustomerfollowfunction() merge range (

'20100101'

)   

新增乙個分割槽:

alter

partition scheme yearcustomerfollow 

next

used [

primary

]     

-- 分割槽方案  

alter

partition 

function

yearcustomerfollowfunction() split range (

'20090101'

)  -- 分界值 

建立分割槽:(這裡的語句可以用嚮導生成更方便)

use [sql_zzw] 

go begin

transaction

create

clustered 

index

[clusteredindex_on_yearcustomerfollow_01] 

on[dbo].[zzw_test]  

( [birthyday] 

)with

(sort_in_tempdb = 

off, ignore_dup_key = 

off, drop_existing = 

off, online = 

off) 

on[yearcustomerfollow]([birthyday]) 

drop

index

[clusteredindex_on_yearcustomerfollow_01] 

on[dbo].[zzw_test] 

with

( online = 

off) 

查詢分割槽表行數.

select

$partition.yearcustomerfollowfunction(birthyday) 

as分割槽編號,

count

(id) 

as記錄數  

from

zzw_test  

group

by$partition.yearcustomerfollowfunction(birthyday)   

二,用嚮導

1,在要修改的表上右鍵->儲存->建立分割槽.

2,選擇分割槽列.

3,建立分割槽函式或選擇以後的分割槽函式.

4,建立分割槽方案或選擇現有分割槽方案.

5,對映分割槽,先設定邊界.

6,可以看到邊界值都一下子已經設定好了.

7,建立完成.

檢視:表右鍵->儲存-管理壓縮.可以看到各分割槽的行數,空間.

在控制台庫->儲存下可以直接看到剛建立的分割槽方案和分割槽函式.

MSSQL2005分割槽表設計步驟

在microsoft sqlserver 2005企業版中提供了分割槽表的功能。分割槽表是指按照資料水平方式分割槽,將資料分布於乙個資料庫的多個不同的檔案組中。mssql2005的表分割槽功能是針對超大型資料庫 從百gb級和tb級 而設計的。通過採取分割槽技術,對於資料子集的執行的維護操作只是針對所...

SQL ON Hadoop Hive(三) 分割槽表

分割槽表是將大的表檔案劃分成多個小檔案以利於查詢,但是如果資料分布不均也會影響查詢效率 桶表可以對資料進行雜湊取模,目的是讓資料能夠均勻分布在表的各個資料檔案中,是對分割槽表的補充 create table info student student id string,name string,age...

ESP32 分割槽表

0x1000 bootloader.bin 0x8000 partition table.bin 0x10000 user.bin 計算 0x8000 0x1000 0x7000 7 16 3 28672 29k 29000。解決方法 idf.py menuconfig bootloader con...