sql 大資料量 的分表操作

來源:互聯網
上載者:User
-- 建立檔案組:use OwnMSDB
go

alter database OwnMSDB add filegroup filegroup1
alter database OwnMSDB add filegroup filegroup2
alter database OwnMSDB add filegroup filegroup3
alter database OwnMSDB add filegroup filegroup4

go

-- 在檔案組中添加檔案 ,一個檔案組可以包含多個檔案,每個檔案代表的是某個表的分表,最好放到不同的磁碟下,可以充分發揮IO的操作速度use OwnMSDB
go

alter database OwnMSDB add file(name=N'TextDataFile',filename=N'C:\sql file group1\TextDataFile1.ndf',size=3072kb,filegrowth=1024KB) to filegroup filegroup1

-- and so on

--表分區步驟
-- 如果資料庫含有大量表格,則把表格分區是很好的最佳化效能的方法

--1 ,建立一個分區函數 how
-- 定義一個分區的函數,來把不同編號的客戶區分出來create partition function customer_partfunc(int)
as range right
for values(250000,500000,750000)

--分區為>=250000 ,250000< >=500000,50000< <=750000,750000<

--2,建立一個分區架構,將分區串連到指定的 到指定的檔案組就行了use OwnMSDB
go
create partition scheme customer_partscheme
as partition customer_partfunc
to(filegroup1,filegroup2,filegroup3,filegroup4)

--3,對一個表分區

create table Customer1(firstname varchar(100),lastname varchar(100),customerid int)
on customer_partscheme(customerid)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.