简体   繁体   中英

SQL Server: Database User Access Mode

With Windows SQL Server there are 3 user access mode settings per DB.

  • Multi_User
  • Single_User
  • Restricted_User

My question is, when exactly do you put a database in the "Single_User" of the "Restricted_User" mode?

For example, if you want to update the SQL Server and thus prevent further sessions from being established for the duration of the update?

Typical Restricted_User and Single_User are used when doing maintenance that needs to be done when the applications are offline but you still need to access the data or schema.

Examples

  • Data migrations that are spanning multiple hours/days accessing multiple tables /databases/files are often done when the system is offline to minimize locking/blocking.
  • Hardware migrations: Typically when moving to new hardware the database is also but in restricted mode before the service is turned off, to make some full backups, put the database offline, ...
  • Recovery: When your database is corrupted an you are restoring logs and performing ddbc checkdb (Although this is mostly done on a separate environment)
  • ...

So basically when the DBAs/Developers wants to make sure nobody else can access the database but they still needs to be able to perform tasks.

In the enterprise environment this is often a fail-safe, as access to the database will probably be limited by firewalls, user policies when doing one of these tasks.

Patching SQL server or the OS is done when the service is stopped, as often OS patches require reboots and SQL Server patches require service restarts. When running in a clustered environment, it's done 1 node at the time, to maintain up-time. So restricted access is not used in these cases as the SQL Server is offline.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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