sys.database_mirroring (Transact-SQL)

 

Updated: June 10, 2016

THIS TOPIC APPLIES TO:yesSQL Server (starting with 2008)noAzure SQL DatabasenoAzure SQL Data Warehouse noParallel Data Warehouse

Contains one row for each database in the instance of SQL Server. If the database is not ONLINE or database mirroring is not enabled, the values of all columns except database_id will be NULL.

To see the row for a database other than master or tempdb, you must either be the database owner or have at least ALTER ANY DATABASE or VIEW ANY DATABASE server-level permission or CREATE DATABASE permission in the master database. To see non-NULL values on a mirror database, you must be a member of the sysadmin fixed server role.

System_CAPS_ICON_note.jpg Note


If a database does not participate in mirroring, all columns prefixed with "mirroring_" are NULL.

Column nameData typeDescription
database_idintID of the database. Is unique within an instance of SQL Server.
mirroring_guiduniqueidentifierID of the mirroring partnership.

NULL= Database is inaccessible or is not mirrored.

Note: If the database does not participate in mirroring, all columns prefixed with "mirroring_" are NULL.
mirroring_statetinyintState of the mirror database and of the database mirroring session.

0 = Suspended

1 = Disconnected from the other partner

2 = Synchronizing

3 = Pending Failover

4 = Synchronized

5 = The partners are not synchronized. Failover is not possible now.

6 = The partners are synchronized. Failover is potentially possible. For information about the requirements for failover see, Database Mirroring Operating Modes.

NULL = Database is inaccessible or is not mirrored.
mirroring_state_descnvarchar(60)Description of the state of the mirror database and of the database mirroring session, can be one of:

DISCONNECTED

SYNCHRONIZED

SYNCHRONIZING

PENDING_FAILOVER

SUSPENDED

UNSYNCHRONIZED

SYNCHRONIZED

NULL

For more information, see Mirroring States (SQL Server).
mirroring_roletinyintCurrent role of the local database plays in the database mirroring session.

1 = Principal

2 = Mirror

NULL = Database is inaccessible or is not mirrored.
mirroring_role_descnvarchar(60)Description of the role the local database plays in mirroring, can be one of:

PRINCIPAL

MIRROR
mirroring_role_sequenceintThe number of times that mirroring partners have switched the principal and mirror roles due to a failover or forced service.

NULL = Database is inaccessible or is not mirrored.
mirroring_safety_leveltinyintSafety setting for updates on the mirror database:

0 = Unknown state

1 = Off [asynchronous]

2 = Full [synchronous]

NULL = Database is inaccessible or is not mirrored.
mirroring_safety_level_descnvarchar(60)Transaction safety setting for the updates on the mirror database, can be one of:

UNKNOWN

OFF

FULL

NULL
mirroring_safety_sequenceintUpdate the sequence number for changes to transaction safety level.

NULL = Database is inaccessible or is not mirrored.
mirroring_partner_namenvarchar(128)Server name of the database mirroring partner.

NULL = Database is inaccessible or is not mirrored.
mirroring_partner_instancenvarchar(128)The instance name and computer name for the other partner. Clients require this information to connect to the partner if it becomes the principal server.

NULL = Database is inaccessible or is not mirrored.
mirroring_witness_namenvarchar(128)Server name of the database mirroring witness.

NULL = No witness exists.
mirroring_witness_statetinyintState of the witness in the database mirroring session of the database, can be one of:

0 = Unknown

1 = Connected

2 = Disconnected

NULL = No witness exists, the database is not online, or the database is not mirrored.
mirroring_witness_state_descnvarchar(60)Description of state, can be one of:

UNKNOWN

CONNECTED

DISCONNECTED

NULL
mirroring_failover_lsnnumeric(25,0)Log sequence number (LSN) of the latest transaction log record that is guaranteed to be hardened to disk on both partners. After a failover, the mirroring_failover_lsn is used by the partners as the point of reconciliation at which the new mirror server begins to synchronize the new mirror database with the new principal database.
mirroring_connection_timeoutintMirroring connection time out in seconds. This is the number of seconds to wait for a reply from a partner or witness before considering them unavailable. The default time-out value is 10 seconds.

NULL = Database is inaccessible or is not mirrored.
mirroring_redo_queueintMaximum amount of log to be redone on the mirror. If mirroring_redo_queue_type is set to UNLIMITED, which is the default setting, this column is NULL. If the database is not online, this column is also NULL.

Otherwise, this column contains the maximum amount of log in megabytes. When the maximum is reached, the log is temporarily stalled on the principal as the mirror server catches up. This feature limits failover time.

For more information, see Estimate the Interruption of Service During Role Switching (Database Mirroring).
mirroring_redo_queue_typenvarchar(60)UNLIMITED indicates that mirroring will not inhibit the redo queue. This is the default setting.

MB for maximum size of the redo queue in mega bytes. Note that if the queue size was specified as kilobytes or gigabytes, the Database Engine converts the value into megabytes.

If the database is not online, this column is NULL.
mirroring_end_of_log_lsnnumeric(25,0)The local end-of-log that has been flushed to disk. This is comparable to the hardened LSN from the mirror server (see the mirroring_failover_lsn column).
mirroring_replication_lsnnumeric(25,0)The maximum LSN that replication can send.

The visibility of the metadata in catalog views is limited to securables that a user either owns or on which the user has been granted some permission. For more information, see Metadata Visibility Configuration.

Catalog Views (Transact-SQL)
ALTER DATABASE (Transact-SQL)
sys.database_mirroring_witnesses (Transact-SQL)
sys.database_mirroring_endpoints (Transact-SQL)
Databases and Files Catalog Views (Transact-SQL)
Querying the SQL Server System Catalog FAQ

Community Additions

ADD
Show: