对于dbcc shrinkfile emptyfile的解释: 将指定文件中的所有数据迁移到同一文件组中的其他文件。由于数据库引擎不再允许将数据放在空文件内,因此可以使用ALTERDATABASE语句来删除该文件。 假设说我现在想将数据从一个磁盘移动到另外一个磁盘,在移动过程中
对于dbcc shrinkfile emptyfile的解释:
将指定文件中的所有数据迁移到同一文件组中的其他文件。由于数据库引擎不再允许将数据放在空文件内,因此可以使用ALTERDATABASE语句来删除该文件。
假设说我现在想将数据从一个磁盘移动到另外一个磁盘,在移动过程中不想数据库Offline,我们可以使用这个选项。下面是一个例子:
感谢您选择使用ERMEB域名授权离线网络验证系统(简称:ERMEB域名授权系统)是ERMEB团队开发,ERMEB域名授权系统是国内最稳定,最强大,最先进的域名授权管理平台解决方案之一,ERMEB域名授权系统采用PHP +Mysql的技术,ERMEB域名授权系统框架使用Thinkphp6/mysql数据库基于Markdown开发者文档开发而成,项目安装请参考ThinkPHP官方文档及下面的服务环境说
0
--create demodatabase
create database test
on primary( name=test,filename='D:\testdata\test_primary.mdf'),
filegroup [seconday]
(name = testsecondary,filename='d:\testdata\test_secondary.ndf')
log on(name = test_log,filename='d:\testdata\test_log.ldf')
--create tableon secondary filegroup
use test
go
create table test(idint) on [seconday]
--Insert Demodata
declare @int int
set @int =0
while @int
begin
insert into testvalues (@int )
set @int = @int+1
end
--Add another dadtafile on secondary file group
alter database test
add file
(name= test_secondary_new,filename='d:\testdata\test_secondary_new.ndf')
to filegroup[seconday]
--Empty oldfile and data will move to another file in the same filegroup
dbccshrinkfile('testsecondary',emptyfile)
go
--Show filesizeafter empty file
dbccshowfilestats
go
--remove old file
alter database test removefiletestsecondary
--drop demodatabase
use master
go
drop database test
使用这个选项不能够移动系统对象,所以有局限性。另外性能上来讲肯定没有detach然后附近来的快,好处是整个数据库不会offline.
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号