简体   繁体   English

SQL Server 2005的文件和文件组

[英]Files and filegroups sql server 2005

Can we move default file to another filegroup. 我们可以将默认文件移动到另一个文件组吗? sample code is given below 示例代码如下

Sample code 样例代码

create database EMPLOYEE
ON PRIMARY
(
NAME = 'PRIMARY_01',
FILENAME = 'C:\METADATA\PRIM01.MDF',
SIZE = 5 MB ,
MAXSIZE =50 MB,
FILEGROWTH = 2 MB),
(
NAME = 'SECONDARY_02',
FILENAME = 'C:\METADATA\SEC02.NDF'
),

FILEGROUP EMPLOYEE_dETAILS
(
NAME = 'EMPDETILS_01',
FILENAME = 'C:\METADATA\EMPDET01.NDF',
SIZE = 5 MB ,
MAXSIZE =50 MB,
FILEGROWTH = 2 MB),
(
NAME = 'EMPDETILS_02',
FILENAME = 'C:\METADATA\EMPDET02.NDF',
SIZE = 5 MB ,
MAXSIZE =50 MB,
FILEGROWTH = 2 MB)

LOG ON
(
NAME = 'TRANSACLOG',
FILENAME ='c:\METADATA\TRAS01.LDF',
SIZE = 5 MB ,
MAXSIZE =50 MB,
FILEGROWTH = 2 MB
)
now i want to move the 现在我想移动
 FILENAME = 'C:\\METADATA\\SEC02.NDF' from deault primary file to the FILEGROUP EMPLOYEE_dETAILS ? 

need assist ?? 需要协助吗?

This cannot be done. 无法做到这一点。 A file group will "contain" one or more files, and those files host the data stored within the filegroup in (or so I've heard) a round-robin fashion -- think of the data as being spread evenly between all files. 文件组将“包含”一个或多个文件,并且这些文件以循环方式(或据我所知)托管文件组中存储的数据-认为数据在所有文件之间均匀分布。 You can direct which file group your data will be stored in, but you have no control over which file within that file group any particular bit of data will be written to. 您可以指示数据将存储在哪个文件组中,但是您无法控制该文件组中的哪个文件将写入任何特定的数据位。 If you somehow moved a file from one file group to another, you'd be moving a random half of that file group's data to another file group that wouldn't know what to do with it, and that would permanently corrupt your database. 如果您以某种方式将文件从一个文件组移动到另一个文件组,则会将该文件组的数据的随机一半移动到另一个文件组,该文件组不知道如何处理该文件,这将永久破坏数据库。

What are you actually trying to do? 您实际上想做什么? Move data stored in a file group into another file group? 将存储在文件组中的数据移动到另一个文件组中? Remove a file from a file group? 从文件组中删除文件? Add a file to a file group? 将文件添加到文件组? (The first can be done by creating a new object in the target file group, copying the data over, dropping the old object, and renaming the new object; the second two can be done via the ALTER DATABASE command.) (第一个可以通过在目标文件组中创建一个新对象,将数据复制过来,删除旧对象并重命名新对象来完成;第二个可以通过ALTER DATABASE命令来完成。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM