SQL Server Database status options

Source: Internet
Author: User
Tags access properties

Option 1,

Single_user (single user), Multi_user (multi-user), Restricted_user (limited user);

Describes the user access properties of the database, which are mutually exclusive, and setting any of these options cancels the setting of the other options

The Single_user mode database can have only one connection at a time.

Restricted_user mode can have multiple connections, provided that these users are considered ' qualified ' as Sysadmin,dbcreator,dbowner.

Multi_user Any valid user can connect.

Example:

ALTER DATABASE Studio
Set Single_user
With
Rollback immediate; ----       | Rollback after 1000|no_wait;
Go

Note: This time only one connection can operate the database, if the other connection wants to manipulate the database, it will fail, not because of its permissions problem, but can only have a connection.

Option 2,

Online, offline, emergency they are mutually exclusive

If the data is set to offline, it is turned off and turned off completely, and is marked as offline and the database cannot be modified when it is offline, if the database

Any connection in the offline can not be marked as a.

Example:

Select Name, State_desc
From sys.databases
where name = ' Studio '

with rollback immediate; ----       | Rollback after 1000|no_wait;
Go

Attention:

For the state of the database we can set is only offline, online,emergency! It's some other state we're not going to be able to set it up

such as: Restore from the backup process will correspond to recovering, if for some reasons there is no way to complete the restoration will correspond to recovery_pending;

such as: During the restore process detected data corruption will correspond to suspect, the database will become completely unavailable, in many cases the database can be set to emergency

So that it can be read-only, if one or more log files of the database are lost, when the database is copied to a new location, the emergency mode also

Access to the database is also possible. When you convert from recovery_pending to emergency, SQL Server shuts down the database and then uses a special tag to re-

Boot, which skips the recovery process, skipping recovery means there may be logical errors or physical inconsistencies (such as index loss, broken pages)

Option 3,

READ_ONLY, Read_write

-----------------------

ALTER DATABASE Studio
Set Read_Only
With
Rollback immediate; ----       | Rollback after 1000|no_wait;
Go

--------------------------------------------------------------------------------------------------------------- -------------------------------------

Status options are available and

Rollback IMMEDIATE | Rollback after 1000 | no_wait;

With

SQL Server Database status options

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.