Sqlserver大資料量分割槽表建立

2021-09-06 13:59:04 字數 4246 閱讀 4023

/*

逆向刪除物件

drop partition scheme [ps_basicpolicy2014];

drop partition function [pf_basicpolicy2014];

alter database [jkgateway] remove file fg_basicpolicy2014_else;

alter database [jkgateway] remove file fg_basicpolicy2014_piaomeng;

alter database [jkgateway] remove file fg_basicpolicy2014_jinri;

alter database [jkgateway] remove file fg_basicpolicy2014_51book;

alter database [jkgateway] remove file fg_basicpolicy2014_19e;

alter database [jkgateway] remove filegroup [fg_basicpolicy2014_else];

alter database [jkgateway] remove filegroup [fg_basicpolicy2014_piaomeng];

alter database [jkgateway] remove filegroup [fg_basicpolicy2014_jinri];

alter database [jkgateway] remove filegroup [fg_basicpolicy2014_51book];

alter database [jkgateway] remove filegroup [fg_basicpolicy2014_19e];

*/--

建立檔案組

alter

database

[jkgateway

]add filegroup [

fg_basicpolicy2014_else];

alter

database

[jkgateway

]add filegroup [

fg_basicpolicy2014_piaomeng];

alter

database

[jkgateway

]add filegroup [

fg_basicpolicy2014_jinri];

alter

database

[jkgateway

]add filegroup [

fg_basicpolicy2014_51book];

alter

database

[jkgateway

]add filegroup [

fg_basicpolicy2014_19e];

--建立檔案

alter

database

[jkgateway

]add

file ( name = n'

fg_basicpolicy2014_else

', filename = n'

e:\sqlserver_filegroup\fg_basicpolicy2014_else.ndf

' , size = 3072kb , filegrowth = 1024kb ) to filegroup [

fg_basicpolicy2014_else];

alter

database

[jkgateway

]add

file ( name = n'

fg_basicpolicy2014_piaomeng

', filename = n'

f:\sqlserver_filegroup\fg_basicpolicy2014_piaomeng.ndf

' , size = 3072kb , filegrowth = 1024kb ) to filegroup [

fg_basicpolicy2014_piaomeng];

alter

database

[jkgateway

]add

file ( name = n'

fg_basicpolicy2014_jinri

', filename = n'

e:\sqlserver_filegroup\fg_basicpolicy2014_jinri.ndf

' , size = 3072kb , filegrowth = 1024kb ) to filegroup [

fg_basicpolicy2014_jinri];

alter

database

[jkgateway

]add

file ( name = n'

fg_basicpolicy2014_51book

', filename = n'

d:\sqlserver_filegroup\fg_basicpolicy2014_51book.ndf

' , size = 3072kb , filegrowth = 1024kb ) to filegroup [

fg_basicpolicy2014_51book];

alter

database

[jkgateway

]add

file ( name = n'

fg_basicpolicy2014_19e

', filename = n'

d:\sqlserver_filegroup\fg_basicpolicy2014_19e.ndf

' , size = 3072kb , filegrowth = 1024kb ) to filegroup [

fg_basicpolicy2014_19e];

--建立分割槽函式

create partition function

[pf_basicpolicy2014

](int) as range right

forvalues ('

1', '

2', '

3', '6'

);--

建立分割槽方案(注意順序:第乙個為other,共它的檔案組對應上面的1,2,3,6,如:fg_basicpolicy2014_piaomeng對應1,fg_basicpolicy2014_jinri對應2,以此類推)

create partition scheme [

ps_basicpolicy2014

]as partition [

pf_basicpolicy2014

]to ([

fg_basicpolicy2014_else

], [

fg_basicpolicy2014_piaomeng

], [

fg_basicpolicy2014_jinri

], [

fg_basicpolicy2014_51book

], [

fg_basicpolicy2014_19e]);

create

table

[policy

].[basicpolicy2014](

[policyid][

int]

identity(1,1) not

forreplication

notnull

, [id

][varchar

](300) not

null

,

[companyid][

int]

notnull

, ...

constraint

[pk_basicpolicy2014

]primary

keyclustered

(

[policyid

]asc

)with (pad_index =

off, statistics_norecompute =

off, ignore_dup_key =

off, allow_row_locks =

on, allow_page_locks =

on) on

[primary])

on[ps_basicpolicy2014

](companyid)

參考資料:

SQL Server大資料量插入

sql server大資料插入方法比較多,下面我們先談談bulk insert 方法。首先,我們建立一張table,如下面t sql指令碼 create table testtable2 id int,amount int check amount 1000 and amount 5000 假設有這...

SQL Server百萬級大資料量刪除

原文 sql server百萬級大資料量刪除 刪除乙個表中的部分資料,資料量百萬級。一般delete from 表 delete from ysh where date 2016 06 21 此操作可能導致,刪除操作執行的時間長 日誌檔案急速增長 針對此情況處理 delete top from de...

大資料量演算法

給40億個不重複的unsigned int的整數,沒排過序的,然後再給乙個數,如何快速判斷這個數是否在那40億個數當中 位圖思想解法 include stdio.h include stdlib.h include memory.h define max num 4294967295 int mai...