master Database

 

The master database records all the system-level information for a SQL Server system. This includes instance-wide metadata such as logon accounts, endpoints, linked servers, and system configuration settings. In SQL Server, system objects are no longer stored in the master database; instead, they are stored in the Resource database. Also, master is the database that records the existence of all other databases and the location of those database files and records the initialization information for SQL Server. Therefore, SQL Server cannot start if the master database is unavailable.

The following table lists the initial configuration values of the master data and log files. The sizes of these files may vary slightly for different editions of SQL Server.

FileLogical namePhysical nameFile growth
Primary datamastermaster.mdfAutogrow by 10 percent until the disk is full.
Logmastlogmastlog.ldfAutogrow by 10 percent to a maximum of 2 terabytes.

For information about how to move the master data and log files, see Move System Databases.

Database Options

The following table lists the default value for each database option in the master database and whether the option can be modified. To view the current settings for these options, use the sys.databases catalog view.

Database optionDefault valueCan be modified
ALLOW_SNAPSHOT_ISOLATIONONNo
ANSI_NULL_DEFAULTOFFYes
ANSI_NULLSOFFYes
ANSI_PADDINGOFFYes
ANSI_WARNINGSOFFYes
ARITHABORTOFFYes
AUTO_CLOSEOFFNo
AUTO_CREATE_STATISTICSONYes
AUTO_SHRINKOFFNo
AUTO_UPDATE_STATISTICSONYes
AUTO_UPDATE_STATISTICS_ASYNCOFFYes
CHANGE_TRACKINGOFFNo
CONCAT_NULL_YIELDS_NULLOFFYes
CURSOR_CLOSE_ON_COMMITOFFYes
CURSOR_DEFAULTGLOBALYes
Database Availability OptionsONLINE

MULTI_USER

READ_WRITE
No

No

No
DATE_CORRELATION_OPTIMIZATIONOFFYes
DB_CHAININGONNo
ENCRYPTIONOFFNo
NUMERIC_ROUNDABORTOFFYes
PAGE_VERIFYCHECKSUMYes
PARAMETERIZATIONSIMPLEYes
QUOTED_IDENTIFIEROFFYes
READ_COMMITTED_SNAPSHOTOFFNo
RECOVERYSIMPLEYes
RECURSIVE_TRIGGERSOFFYes
Service Broker OptionsDISABLE_BROKERNo
TRUSTWORTHYOFFYes

For a description of these database options, see ALTER DATABASE (Transact-SQL).

The following operations cannot be performed on the master database:

  • Adding files or filegroups.

  • Changing collation. The default collation is the server collation.

  • Changing the database owner. master is owned by sa.

  • Creating a full-text catalog or full-text index.

  • Creating triggers on system tables in the database.

  • Dropping the database.

  • Dropping the guest user from the database.

  • Enabling change data capture.

  • Participating in database mirroring.

  • Removing the primary filegroup, primary data file, or log file.

  • Renaming the database or primary filegroup.

  • Setting the database to OFFLINE.

  • Setting the database or primary filegroup to READ_ONLY.

When you work with the master database, consider the following recommendations:

  • Always have a current backup of the master database available.

  • Back up the master database as soon as possible after the following operations:

    • Creating, modifying, or dropping any database

    • Changing server or database configuration values

    • Modifying or adding logon accounts

  • Do not create user objects in master. If you do, master must be backed up more frequently.

  • Do not set the TRUSTWORTHY option to ON for the master database.

If master becomes unusable, you can return the database to a usable state in either of the following ways:

  • Restore master from a current database backup.

    If you can start the server instance, you should be able to restore master from a full database backup. For more information, see Restore the master Database (Transact-SQL).

  • Rebuild master completely.

    If severe damage to master prevents you from starting SQL Server, you must rebuild master. For more information, see Rebuild System Databases.

    System_CAPS_ICON_important.jpg Important


    Rebuilding master rebuilds all of the system databases.

Rebuild System Databases

System Databases

sys.databases (Transact-SQL)

sys.master_files (Transact-SQL)

Move Database Files

Show: