Skip to content

Commit 3c9b3da

Browse files
committed
Merge branch 'main' into release-bdc-2022
2 parents 2c2f072 + 75b1aa1 commit 3c9b3da

1 file changed

Lines changed: 5 additions & 52 deletions

File tree

docs/t-sql/statements/alter-database-transact-sql-set-options.md

Lines changed: 5 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -2694,31 +2694,6 @@ When encryption is enabled at the database level, all file groups will be encryp
26942694

26952695
You can see the encryption state of the database by using the [sys.dm_database_encryption_keys](../../relational-databases/system-dynamic-management-views/sys-dm-database-encryption-keys-transact-sql.md) dynamic management view.
26962696

2697-
#### **\<db_update_option> ::=**
2698-
Controls whether updates are allowed on the database.
2699-
2700-
READ_ONLY
2701-
Users can read data from the database but not modify it.
2702-
2703-
> [!NOTE]
2704-
> To improve query performance, update statistics before setting a database to READ_ONLY. If additional statistics are needed after a database is set to READ_ONLY, the [!INCLUDE[ssDE](../../includes/ssde-md.md)] will create statistics in `tempdb`. For more information about statistics for a read-only database, see [Statistics](../../relational-databases/statistics/statistics.md).
2705-
2706-
READ_WRITE
2707-
The database is available for read and write operations.
2708-
2709-
To change this state, you must have exclusive access to the database.
2710-
2711-
#### **\<db_user_access_option> ::=**
2712-
Controls user access to the database.
2713-
2714-
RESTRICTED_USER
2715-
Allows for only members of the `db_owner` fixed database role and `dbcreator` and `sysadmin` fixed server roles to connect to the database, but doesn't limit their number. All connections to the database are disconnected in the timeframe specified by the termination clause of the ALTER DATABASE statement. After the database has transitioned to the RESTRICTED_USER state, connection attempts by unqualified users are refused. **RESTRICTED_USER** can't be modified with SQL Managed Instance.
2716-
2717-
MULTI_USER
2718-
All users that have the appropriate permissions to connect to the database are allowed.
2719-
2720-
You can determine this option's status by examining the `user_access` column in the [sys.databases](../../relational-databases/system-catalog-views/sys-databases-transact-sql.md) catalog view or the `UserAccess` property of the [DATABASEPROPERTYEX](../../t-sql/functions/databasepropertyex-transact-sql.md) function.
2721-
27222697
#### **\<delayed_durability_option> ::=**
27232698
Controls whether transactions commit fully durable or delayed durable.
27242699

@@ -2848,8 +2823,6 @@ When you set ALLOW_SNAPSHOT_ISOLATION to a new state (from ON to OFF, or from OF
28482823

28492824
You can't change the state of ALLOW_SNAPSHOT_ISOLATION if the database is OFFLINE.
28502825

2851-
If you set ALLOW_SNAPSHOT_ISOLATION in a READ_ONLY database, the setting will be kept if the database is later set to READ_WRITE.
2852-
28532826
You can change the ALLOW_SNAPSHOT_ISOLATION settings for the `master`, `model`, `msdb`, and `tempdb` databases. The setting is kept every time the instance of the [!INCLUDE[ssDE](../../includes/ssde-md.md)] is stopped and restarted if you change the setting for `tempdb`. If you change the setting for the `model` system database, that setting becomes the default for any new databases that are created, except for `tempdb`.
28542827

28552828
The option is ON, by default, for the `master` and `msdb` databases.
@@ -2865,8 +2838,6 @@ Turns off the Read-Committed Snapshot option at the database level. Transactions
28652838

28662839
To set READ_COMMITTED_SNAPSHOT to ON or OFF, there must be no active connections to the database except for the connection running the ALTER DATABASE command. However, the database doesn't have to be in single-user mode. You can't change the state of this option when the database is OFFLINE.
28672840

2868-
If you set READ_COMMITTED_SNAPSHOT in a READ_ONLY database, the setting will be kept when the database is later set to READ_WRITE.
2869-
28702841
READ_COMMITTED_SNAPSHOT can't be turned ON for the `master`, `tempdb`, or `msdb` system databases. If you change the setting for the `model` system database, that setting becomes the default for any new databases created, except for `tempdb`.
28712842

28722843
The current setting of this option can be determined by examining the `is_read_committed_snapshot_on` column in the [sys.databases](../../relational-databases/system-catalog-views/sys-databases-transact-sql.md) catalog view.
@@ -3075,28 +3046,10 @@ You can change the default values for any one of the database options for all ne
30753046

30763047
## Examples
30773048

3078-
### A. Setting the database to READ_ONLY
3079-
Changing the state of a database or file group to READ_ONLY or READ_WRITE requires exclusive access to the database. The following example sets the database to `RESTRICTED_USER` mode to restricted access. The example then sets the state of the [!INCLUDE[ssSampleDBobject](../../includes/sssampledbobject-md.md)] database to `READ_ONLY` and returns access to the database to all users.
3080-
3081-
```sql
3082-
USE master;
3083-
GO
3084-
ALTER DATABASE [database_name]
3085-
SET RESTRICTED_USER;
3086-
GO
3087-
ALTER DATABASE [database_name]
3088-
SET READ_ONLY
3089-
GO
3090-
ALTER DATABASE [database_name]
3091-
SET MULTI_USER;
3092-
GO
3093-
```
3094-
3095-
### B. Enabling snapshot isolation on a database
3049+
### A. Enabling snapshot isolation on a database
30963050
The following example enables the snapshot isolation framework option for the [!INCLUDE[ssSampleDBobject](../../includes/sssampledbobject-md.md)] database.
30973051

30983052
```sql
3099-
USE [database_name];
31003053
USE master;
31013054
GO
31023055
ALTER DATABASE [database_name]
@@ -3117,7 +3070,7 @@ The result set shows that the snapshot isolation framework is enabled.
31173070
|-------------------- |------------------------|----------|
31183071
|[database_name] |1| ON |
31193072

3120-
### C. Enabling, modifying, and disabling change tracking
3073+
### B. Enabling, modifying, and disabling change tracking
31213074
The following example enables change tracking for the [!INCLUDE[ssSampleDBobject](../../includes/sssampledbobject-md.md)] database and sets the retention period to `2` days.
31223075

31233076
```sql
@@ -3140,7 +3093,7 @@ ALTER DATABASE [database_name]
31403093
SET CHANGE_TRACKING = OFF;
31413094
```
31423095

3143-
### D. Enabling the Query Store
3096+
### C. Enabling the Query Store
31443097
The following example enables the Query Store and configures Query Store parameters.
31453098

31463099
```sql
@@ -3156,7 +3109,7 @@ SET QUERY_STORE = ON
31563109
);
31573110
```
31583111

3159-
### E. Enabling the Query Store with wait statistics
3112+
### D. Enabling the Query Store with wait statistics
31603113
The following example enables the Query Store and configures its parameters.
31613114

31623115
```sql
@@ -3174,7 +3127,7 @@ SET QUERY_STORE = ON
31743127
);
31753128
```
31763129

3177-
### F. Enabling the Query Store with custom capture policy options
3130+
### E. Enabling the Query Store with custom capture policy options
31783131
The following example enables the Query Store and configures its parameters.
31793132

31803133
```sql

0 commit comments

Comments
 (0)