Contains one row per database in the instance of SQL Server.
Applies to: SQL Server (SQL Server 2008 through current version), Azure SQL Database.
If a database is not ONLINE, or AUTO_CLOSE is set to ON and the database is closed, the values of some columns may be NULL. If a database is OFFLINE, the corresponding row is not visible to low-privileged users. To see the corresponding row if the database is OFFLINE, a user must have at least the ALTER ANY DATABASE server-level permission, or the CREATE DATABASE permission in the master database.
Columns that are relevant to Active Geo-Replication for SQL Database: is_ready_only, state, and state_desc.
Name of database, unique within an instance of SQL Server or within a Azure SQL Database server.
ID of the database, unique within an instance of SQL Server or within a Azure SQL Database server.
Non-NULL = ID of the source database of this database snapshot.
NULL = Not a database snapshot.
SID (Security-Identifier) of the external owner of the database, as registered to the server.
Date the database was created or renamed. For tempdb, this value changes every time the server restarts.
Integer corresponding to the version of SQL Server for which behavior is compatible:
Collation for the database. Acts as the default collation in the database.
NULL = Database is not online or AUTO_CLOSE is set to ON and the database is closed.
0 = MULTI_USER specified
1 = SINGLE_USER specified
2 = RESTRICTED_USER specified
Description of user-access setting.
1 = Database is READ_ONLY
0 = Database is READ_WRITE
1 = AUTO_CLOSE is ON
0 = AUTO_CLOSE is OFF
1 = AUTO_SHRINK is ON
0 = AUTO_SHRINK is OFF
Description of the database state.
Database is read-only for restore log.
1 = Database shut down cleanly; no recovery required on startup
0 = Database did not shut down cleanly; recovery is required on startup
1 = SUPPLEMENTAL_LOGGING is ON
0 = SUPPLEMENTAL_LOGGING is OFF
State of snapshot-isolation transactions being allowed, as set by the ALLOW_SNAPSHOT_ISOLATION option:
0 = Snapshot isolation state is OFF (default). Snapshot isolation is disallowed.
1 = Snapshot isolation state ON. Snapshot isolation is allowed.
2 = Snapshot isolation state is in transition to OFF state. All transactions have their modifications versioned. Cannot start new transactions using snapshot isolation. The database remains in the transition to OFF state until all transactions that were active when ALTER DATABASE was run can be completed.
3 = Snapshot isolation state is in transition to ON state. New transactions have their modifications versioned. Transactions cannot use snapshot isolation until the snapshot isolation state becomes 1 (ON). The database remains in the transition to ON state until all update transactions that were active when ALTER DATABASE was run can be completed.
Description of state of snapshot-isolation transactions being allowed, as set by the ALLOW_SNAPSHOT_ISOLATION option.
1 = READ_COMMITTED_SNAPSHOT option is ON. Read operations under the read-committed isolation level are based on snapshot scans and do not acquire locks.
0 = READ_COMMITTED_SNAPSHOT option is OFF (default). Read operations under the read-committed isolation level use share locks.
Recovery model selected:
1 = FULL
2 = BULK_LOGGED
3 = SIMPLE
Description of recovery model selected.
Setting of PAGE_VERIFY option:
0 = NONE
1 = TORN_PAGE_DETECTION
2 = CHECKSUM
Description of PAGE_VERIFY option setting.
1 = AUTO_CREATE_STATISTICS is ON
0 = AUTO_CREATE_STATISTICS is OFF
1 = AUTO_UPDATE_STATISTICS is ON
0 = AUTO_UPDATE_STATISTICS is OFF
1 = AUTO_UPDATE_STATISTICS_ASYNC is ON
0 = AUTO_UPDATE_STATISTICS_ASYNC is OFF
1 = ANSI_NULL_DEFAULT is ON
0 = ANSI_NULL_DEFAULT is OFF
1 = ANSI_NULLS is ON
0 = ANSI_NULLS is OFF
1 = ANSI_PADDING is ON
0 = ANSI_PADDING is OFF
1 = ANSI_WARNINGS is ON
0 = ANSI_WARNINGS is OFF
1 = ARITHABORT is ON
0 = ARITHABORT is OFF
1 = CONCAT_NULL_YIELDS_NULL is ON
0 = CONCAT_NULL_YIELDS_NULL is OFF
1 = NUMERIC_ROUNDABORT is ON
0 = NUMERIC_ROUNDABORT is OFF
1 = QUOTED_IDENTIFIER is ON
0 = QUOTED_IDENTIFIER is OFF
1 = RECURSIVE_TRIGGERS is ON
0 = RECURSIVE_TRIGGERS is OFF
1 = CURSOR_CLOSE_ON_COMMIT is ON
0 = CURSOR_CLOSE_ON_COMMIT is OFF
1 = CURSOR_DEFAULT is local
0 = CURSOR_DEFAULT is global
1 = Full-text is enabled for the database
0 = Full-text is disabled for the database
1 = Database has been marked trustworthy
0 = Database has not been marked trustworthy
1 = Cross-database ownership chaining is ON
0 = Cross-database ownership chaining is OFF
1 = Parameterization is FORCED
0 = Parameterization is SIMPLE
1 = Database has an encrypted master key
0 = Database does not have an encrypted master key
1 = Database is a publication database in a transactional or snapshot replication topology
0 = Is not a publication database
This column is not used. It will always return 0, regardless of the subscriber status of the database.
1 = Database is a publication database in a merge replication topology
0 = Is not a publication database in a merge replication topology
1 = Database is the distribution database for a replication topology
0 = Is not the distribution database for a replication topology
1 = Database is marked for replication synchronization with backup
0 = Is not marked for replication synchronization with backup
Identifier of the service broker for this database. Used as the broker_instance of the target in the routing table.
1 = The broker in this database is currently sending and receiving messages.
0 = All sent messages will stay on the transmission queue and received messages will not be put on queues in this database.
By default, restored or attached databases have the broker disabled. The exception to this is database mirroring where the broker is enabled after failover.
Reuse of transaction log space is currently waiting on one of the following as of the last checkpoint:
Description of reuse of transaction log space is currently waiting on as of the last checkpoint.
1 = DATE_CORRELATION_OPTIMIZATION is ON
0 = DATE_CORRELATION_OPTIMIZATION is OFF
1 = Database is enabled for change data capture. For more information, see sys.sp_cdc_enable_db (Transact-SQL).
Indicates whether the database is encrypted (reflects the state last set by using the ALTER DATABASE SET ENCRYPTION clause). Can be one of the following values:
1 = Encrypted
0 = Not Encrypted
For more information about database encryption, see Transparent Data Encryption (TDE).
If the database is in the process of being decrypted, is_encrypted shows a value of 0. You can see the state of the encryption process by using the sys.dm_database_encryption_keys dynamic management view.
Indicates whether the database honors conversation priorities (reflects the state last set by using the ALTER DATABASE SET HONOR_BROKER_PRIORITY clause). Can be one of the following values:
1 = HONOR_BROKER_PRIORITY is ON
0 = HONOR_BROKER_PRIORITY is OFF
Unique identifier of the local AlwaysOn Availability Groups availability replica of the availability group, if any, in which the database is participating.
NULL = database is not part of an availability replica of in availability group.
Unique identifier of the database within an AlwaysOn availability group, if any, in which the database is participating. group_database_id is the same for this database on the primary replica and on every secondary replica on which the database has been joined to the availability group.
NULL = database is not part of an availability replica in any availability group.
Indicates the local id (lcid) of the default language of a contained database.
Note Functions as the Configure the default language Server Configuration Option of sp_configure. This value is null for a non-contained database.
Indicates the default language of a contained database.
This value is null for a non-contained database.
Indicates the local id (lcid) of the default fulltext language of the contained database.
Note Functions as the default Configure the default full-text language Server Configuration Option of sp_configure. This value is null for a non-contained database.
Indicates the default fulltext language of the contained database.
This value is null for a non-contained database.
Indicates whether or not nested triggers are allowed in the contained database.
0 = nested triggers are not allowed
1 = nested triggers are allowed
Note Functions as the Configure the nested triggers Server Configuration Option of sp_configure. This value is null for a non-contained database. See sys.configurations (Transact-SQL) for further information.
Indicates whether or noise words should be transformed in the contained database.
0 = noise words should not be transformed.
1 = noise words should be transformed.
Note Functions as the transform noise words Server Configuration Option of sp_configure. This value is null for a non-contained database. See sys.configurations (Transact-SQL) for further information.
Indicates a value of a number between 1753 and 9999 to represent the cutoff year for interpreting two-digit years as four-digit years.
Note Functions as the Configure the two digit year cutoff Server Configuration Option of sp_configure. This value is null for a non-contained database. See sys.configurations (Transact-SQL) for further information.
tinyint not null
Indicates the containment status of the database.
nvarchar(60) not null
Indicates the containment status of the database.
NONE = legacy database (zero containment)
PARTIAL = partially contained database
The estimated time to recover the database, in seconds. Nullable.
Indicates if the database is a member of a federation.
Memory-optimized tables are accessed using SNAPSHOT isolation when the session setting TRANSACTION ISOLATION LEVEL is set to a lower isolation level, READ COMMITTED or READ UNCOMMITTED.
1 = Minimum isolation level is SNAPSHOT.
0 = Isolation level is not elevated.
Indicates the default setting for the incremental option of auto stats.
0 = auto create stats are non-incremental
1 = auto create stats are incremental if possible
For internal use only.
The id of the resource pool that is mapped to this database. This resource pool controls total memory available to memory-optimized tables in this database.
If the caller of sys.databases is not the owner of the database and the database is not master or tempdb, the minimum permissions required to see the corresponding row are ALTER ANY DATABASE or VIEW ANY DATABASE server-level permission, or CREATE DATABASE permission in the master database. The database to which the caller is connected can always be viewed in sys.databases.
In SQL Database, this view is available in the master database and in user databases. In the master database, this view returns the information on the master database and all user databases on the server. In a user database, this view returns information only on the current database and the master database.
Use the sys.databases view in the master database of the SQL Database server where the new database is being created. After the database copy starts, you can query the sys.databases and the sys.dm_database_copies views from the master database of the destination server to retrieve more information about the copying progress.
A. Query the sys.databases view
The following example returns a few of the columns available in the sys.databases view.
SELECT name, user_access_desc, is_read_only, state_desc, recovery_model_desc FROM sys.databases;
B. Check the copying status in SQL Database
The following example queries the sys.databases and sys.dm_database_copies views to return information about a database copy operation.
Applies to: Azure SQL Database
-- Execute from the master database. SELECT a.name, a.state_desc, b.start_date, b.modify_date, b.percentage_complete FROM sys.databases AS a INNER JOIN sys.dm_database_copies AS b ON a.database_id = b.database_id WHERE a.state = 7;