Table of Contents
2:为分区组指定分区文件,我把分区文件放到不同的盘符下面,这样读取文件就会更快,可以并行的读取文件。这个也是分区能够提高效率的原理。
3:建立分区函数,这个需要和分区组表匹配
3:建立分区结构,将分区函数和分区组对应起来
4:建立分区索引
Home Database Mysql Tutorial sqlserver2008对字符串日期字段分区

sqlserver2008对字符串日期字段分区

Jun 07, 2016 pm 03:59 PM
Partition Field string date

最近对公司产品的日志数据库做了一个数据分区,数据库使用的是sql server 2008,这里给大家提供一个参考。 需要特别说明的是,很多网上的例子分区字段都使用的是时间类型的,而这里由于时间字段原来设计数据库使用的是字符串类型的。所以这里的分区字段使用的

最近对公司产品的日志数据库做了一个数据分区,数据库使用的是sql server 2008,这里给大家提供一个参考。

需要特别说明的是,很多网上的例子分区字段都使用的是时间类型的,而这里由于时间字段原来设计数据库使用的是字符串类型的。所以这里的分区字段使用的是字符串类型的,进过我的测试,也能成功。

1:建立分区组:建立了十个分区组
go
alter database M2
add filegroup [FG1];
go
alter database M2
add filegroup [FG2];
go
alter database M2
add filegroup [FG3];
go
alter database M2
add filegroup [FG4];
go
alter database M2
add filegroup [FG5];
go
alter database M2
add filegroup [FG6];
go
alter database M2
add filegroup [FG7];
go
alter database M2
add filegroup [FG8];
go
alter database M2
add filegroup [FG9];

go
Copy after login

2:为分区组指定分区文件,我把分区文件放到不同的盘符下面,这样读取文件就会更快,可以并行的读取文件。这个也是分区能够提高效率的原理。

alter database M2
addfile(name=FG1_data,filename='c:\esafenet\FG1_data.ndf',size=10MB) tofilegroup[FG1];
alter database M2
addfile(name=FG2_data,filename='c:\esafenet\FG2_data.ndf',size=10MB) tofilegroup[FG2];
alter database M2
addfile(name=FG3_data,filename='d:\esafenet\FG3_data.ndf',size=10MB) tofilegroup[FG3];
alter database M2
addfile(name=FG4_data,filename='d:\esafenet\FG4_data.ndf',size=10MB) tofilegroup[FG4];
alter database M2
addfile(name=FG5_data,filename='e:\esafenet\FG5_data.ndf',size=10MB) tofilegroup[FG5];
alter database M2
addfile(name=FG6_data,filename='d:\esafenet\FG6_data.ndf',size=10MB) tofilegroup[FG6];
alter database M2
addfile(name=FG7_data,filename='f:\esafenet\FG7_data.ndf',size=10MB) tofilegroup[FG7];
alter database M2
addfile(name=FG8_data,filename='f:\esafenet\FG8_data.ndf',size=10MB) tofilegroup[FG8];
alter database M2
addfile(name=FG9_data,filename='c:\esafenet\FG9_data.ndf',size=10MB) tofilegroup[FG9];
go
Copy after login

3:建立分区函数,这个需要和分区组表匹配

Create partitionfunction
Part_mediasec_func(nvarchar(30))as
range left
for values('2013123123:59:59',
           '20141231 23:59:59',
           '20151231 23:59:59',
           '20161231 23:59:59',
           '20171231 23:59:59',
           '20181231 23:59:59',
           '20191231 23:59:59',
           '20201231 23:59:59',
           '20211231 23:59:59');
go
Copy after login

3:建立分区结构,将分区函数和分区组对应起来

Create partitionscheme Part_mediasec_scheme
as partitionPart_mediasec_func
to([FG1],[FG2],[FG3],[FG4],[FG5],[FG6],[FG7],[FG8],[FG9],[Primary]);
go
Copy after login

4:建立分区索引

EXEC sp_helpindexN'SecureUsbLog' --查看原来索引
alter tableSecureUsbLog drop constraint PK__SecureUs__7839F64D1F98B2C1
go
create clusteredindex SecureUsbLog_index
onSecureUsbLog(logTime)
onPart_mediasec_scheme(logTime);
Go
Copy after login

这次分区的特点有两个:

1:对已经使用的数据库进行分区,网上大多数例子是新建的分区和数据库。

2:对字符串类型日期进行分区。

这两点还是很有参考价值的。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1658
14
PHP Tutorial
1257
29
C# Tutorial
1231
24
How to search previous Weibo by date on Weibo_How to search previous Weibo by date on Weibo How to search previous Weibo by date on Weibo_How to search previous Weibo by date on Weibo Mar 30, 2024 pm 07:26 PM

1. First open the mobile web browser, search for the Weibo web version, and click the avatar button in the upper left corner after entering. 2. Then click Settings in the upper right corner. 3. Click the version switching option in settings. 4. Then select the color version option in the version switch. 5. Click Search to enter the search page. 6. After entering the keywords, click Find People. 7. When the search completion interface appears, click Filter. 8. Finally, enter the specific date in the release time column and click Filter.

How to remove the date that appears automatically when printing from PPT handouts How to remove the date that appears automatically when printing from PPT handouts Mar 26, 2024 pm 08:16 PM

1. Let me first talk about the method I used at the beginning, maybe everyone is using it too. First, open [View]——]Remarks Template[. 2. A place where you can actually see the date after opening it. 3. Select it first and delete it. 4. After deleting, click [Close Master View]. 5. Open the print preview again and find that the date is still there. 6. In fact, this date was not deleted here. It should be in the [Handout Master]. Look at the picture below. 7. Delete the date after you find it. 8. Now when you open the preview and take a look, the date is no longer there. Note: In fact, this method is also very easy to remember, because the printed handouts are handouts, so you should look for the [Handout Master].

How to change the date into a pound sign in Excel How to change the date into a pound sign in Excel Mar 20, 2024 am 11:46 AM

Excel software has very powerful data processing functions. We often use excel software to process various data. Sometimes when we enter a date in an excel cell, the date in excel changes to a pound sign. How can we display the data normally? Let’s take a look at the solution below. 1. First, we put the mouse on the column width line between columns AB, double-click and adjust the column width, as shown in the figure below. 2. After the column is widened, we find that numbers are displayed in the cells instead of dates. This is definitely incorrect. Then we should check the format of the cells, as shown in the figure below. 3. Click the "Number" option in the "Home" tab, and click "Other Number Format" in the drop-down menu, as shown in the figure below.

Detailed explanation of the method of converting int type to string in PHP Detailed explanation of the method of converting int type to string in PHP Mar 26, 2024 am 11:45 AM

Detailed explanation of the method of converting int type to string in PHP In PHP development, we often encounter the need to convert int type to string type. This conversion can be achieved in a variety of ways. This article will introduce several common methods in detail, with specific code examples to help readers better understand. 1. Use PHP’s built-in function strval(). PHP provides a built-in function strval() that can convert variables of different types into string types. When we need to convert int type to string type,

How to determine whether a Golang string ends with a specified character How to determine whether a Golang string ends with a specified character Mar 12, 2024 pm 04:48 PM

Title: How to determine whether a string ends with a specific character in Golang. In the Go language, sometimes we need to determine whether a string ends with a specific character. This is very common when processing strings. This article will introduce how to use the Go language to implement this function, and provide code examples for your reference. First, let's take a look at how to determine whether a string ends with a specified character in Golang. The characters in a string in Golang can be obtained through indexing, and the length of the string can be

How to repeat a string in python_python repeating string tutorial How to repeat a string in python_python repeating string tutorial Apr 02, 2024 pm 03:58 PM

1. First open pycharm and enter the pycharm homepage. 2. Then create a new python script, right-click - click new - click pythonfile. 3. Enter a string, code: s="-". 4. Then you need to repeat the symbols in the string 20 times, code: s1=s*20. 5. Enter the print output code, code: print(s1). 6. Finally run the script and you will see our return value at the bottom: - repeated 20 times.

How to intercept a string in Go language How to intercept a string in Go language Mar 13, 2024 am 08:33 AM

Go language is a powerful and flexible programming language that provides rich string processing functions, including string interception. In the Go language, we can use slices to intercept strings. Next, we will introduce in detail how to intercept strings in Go language, with specific code examples. 1. Use slicing to intercept a string. In the Go language, you can use slicing expressions to intercept a part of a string. The syntax of slice expression is as follows: slice:=str[start:end]where, s

Detailed explanation of how to set up Linux Opt partition Detailed explanation of how to set up Linux Opt partition Mar 20, 2024 am 11:30 AM

How to set up the Linux Opt partition and code examples In Linux systems, the Opt partition is usually used to store optional software packages and application data. Properly setting the Opt partition can effectively manage system resources and avoid problems such as insufficient disk space. This article will detail how to set up a LinuxOpt partition and provide specific code examples. 1. Determine the partition space size. First, we need to determine the space size required for the Opt partition. It is generally recommended to set the size of the Opt partition to 5%-1 of the total system space.

See all articles