Repair the database using DBCC CHECKDB
2016-03-27 15:56
801 查看
So now if you want to place AdventureWorks2008R2 sample database in a single-user mode, then write the code
The above code would wait indefinitely if there is a lock on the database or users are connected to the database. So to overcome this situation, use the code below
If the AUTO_UPDATE_STATISTICS_AYSYNC option for the database is ON, then you will be unable to place the database in single-user mode because the background thread that is used to update the statistics takes a connection against the database.
The DBCC offers two repair modes:
REPAIR_REBUILD: This performs a repair that does not lead to any data loss.
REPAIR_ALLOW_DATA_LOSS: This performs a repair and fixes to the corrupted database structures, and also results in data loss.
The following example will let you understand the whole concept, where I have used DBCC CHECKDB with REPAIR_ALLOW_DATA_LOSS option;
http://www.sqlservergeeks.com/repair-the-database-using-dbcc-checkdb/ https://msdn.microsoft.com/en-us/library/ms176064.aspx
ALTER DATABASE AdventureWorks2008R2 SET SINGLE_USER;
The above code would wait indefinitely if there is a lock on the database or users are connected to the database. So to overcome this situation, use the code below
ALTER DATABASE AdventureWorks2008R2 SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
If the AUTO_UPDATE_STATISTICS_AYSYNC option for the database is ON, then you will be unable to place the database in single-user mode because the background thread that is used to update the statistics takes a connection against the database.
The DBCC offers two repair modes:
REPAIR_REBUILD: This performs a repair that does not lead to any data loss.
REPAIR_ALLOW_DATA_LOSS: This performs a repair and fixes to the corrupted database structures, and also results in data loss.
The following example will let you understand the whole concept, where I have used DBCC CHECKDB with REPAIR_ALLOW_DATA_LOSS option;
ALTER DATABASE AdventureWorks2008R2 SET SINGLE_USER WITH ROLLBACK IMMEDIATE; BEGIN TRANSACTION; DBCC CHECKDB ('AdventureWorks2008R2', REPAIR_ALLOW_DATA_LOSS); ALTER DATABASE AdventureWorks2008R2 SET MULTI_USER;
http://www.sqlservergeeks.com/repair-the-database-using-dbcc-checkdb/ https://msdn.microsoft.com/en-us/library/ms176064.aspx
相关文章推荐
- GDC2016 Epic Games【Bullet Train】 新风格的VR-FPS的制作方法
- debain jessie 安装opencv2.4.11 以及 安装 ffmpeg注意事项
- AIX6开启NFS服务
- 理解cookie的path和domain属性(转)
- 跨域中的crossdomain文件
- 我的思考,我的科技漫谈——Tay Tweets
- hdoj-1982-Kaitou Kid - The Phantom Thief (1)
- 03-树3 Tree Traversals Again (25分)
- 检查C语言的内存问题 参考网址:http://blog.csdn.net/sduliulun/article/details/7732906
- 对raid几个技术的简单理解
- arithmetic daily
- main函数中两个参数的用法总结
- 【Educational Codeforces Round 10C】【脑洞 SET】Foe Pairs 不含有敌对pair的区间数
- 我的第一个 Rails 站点:极简优雅的笔记工具-Raysnote
- raid详解
- hangdain 2013
- 使用wait、notify简单实现并行计算
- 浙江科技学院第十三届程序设计竞赛 1008:A Heavy Rainy Day【贪心】
- hdoj--A Heavy Rainy Day(贪心好题)
- LeetCode172. Factorial Trailing Zeroes