Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize Table Partition in SQL server 2005

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article introduces the knowledge of "how to achieve table partitioning in SQL server 2005". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Use master

IF EXISTS (SELECT name FROM sys.databases WHERE name = N'Data Partition DB3')

DROP DATABASE [Data Partition DB3]

GO

CREATE DATABASE [Data Partition DB3]

ON PRIMARY

(NAME='Data Partition DB Primary FG3'

FILENAME=

'C:\ Data2\ Primary\ Data Partition DB Primary FG3.mdf'

SIZE=5

MAXSIZE=500

FILEGROWTH=1)

FILEGROUP [Data Partition DB3 FG1]

(NAME = 'Data Partition DB3 FG1'

FILENAME =

'C:\ Data2\ FG1\ Data Partition DB3 FG1.ndf'

SIZE = 5MB

MAXSIZE=500

FILEGROWTH=1)

FILEGROUP [Data Partition DB3 FG2]

(NAME = 'Data Partition DB3 FG2'

FILENAME =

'C:\ Data2\ FG2\ Data Partition DB3 FG2.ndf'

SIZE = 5MB

MAXSIZE=500

FILEGROWTH=1)

FILEGROUP [Data Partition DB3 FG3]

(NAME = 'Data Partition DB3 FG3'

FILENAME =

'C:\ Data2\ FG3\ Data Partition DB3 FG3.ndf'

SIZE = 5MB

MAXSIZE=500

FILEGROWTH=1)

FILEGROUP [Data Partition DB3 FG4]

(NAME = 'Data Partition DB3 FG4'

FILENAME =

'C:\ Data2\ FG4\ Data Partition DB3 FG4.ndf'

SIZE = 5MB

MAXSIZE=500

FILEGROWTH=1)

Then create a data table:

USE [Data Partition DB3]

Go

CREATE TABLE MyTable

(ID INT NOT NULL

Date DATETIME

Cost money) on [primary]

And set up an index

USE [Data Partition DB3]

Go

CREATE UNIQUE CLUSTERED INDEX MyTable_IXC

ON MyTable (ID) on [PRIMARY]

Next, add data to the table.

USE [Data Partition DB3]

Go

Declare @ count int

Set @ count =-25

While @ count

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report