Heim  >  Artikel  >  Datenbank  >  在数据库恢复之前将数据库置为单用户模式

在数据库恢复之前将数据库置为单用户模式

WBOY
WBOYOriginal
2016-06-07 17:39:431396Durchsuche

今天被朋友问到,他想通过一个脚本自动地对数据库进行还原。但经常遇到的情况是:试图还原的时候,因为有活动的用户连接,所以还原无法完成 要解决该问题,可以在还原之前运行下面的脚本,将数据库置为单用户模式 USE [master] GO ALTER DATABASE [Northwind

今天被朋友问到,他想通过一个脚本自动地对数据库进行还原。但经常遇到的情况是:试图还原的时候,香港服务器,因为有活动的用户连接,所以还原无法完成

image

要解决该问题,可以在还原之前运行下面的脚本,网站空间,将数据库置为单用户模式

USE [master]

GO

ALTER DATABASE [Northwind] SET SINGLE_USER WITH ROLLBACK IMMEDIATE

GO

ALTER DATABASE [Northwind] SET SINGLE_USER

GO

以上设置将强制回滚所有没有提交的事务,在进行还原之后,服务器空间,你可以再将其设置回多用户状态

USE [master]

GO

ALTER DATABASE [Northwind] SET MULTI_USER WITH ROLLBACK IMMEDIATE

GO

ALTER DATABASE [Northwind] SET MULTI_USER

GO

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn