What are the system databases on MSSQL and their purpose
Microsoft SQL Server uses 6 databases for operating:
- master
- resource
- model
- msdb
- distribution
- tempdb
Applies to:
- Microsoft SQL Server 2005
Files
| Database | .mdf file | .ldf file |
|---|---|---|
| master | master.mdf | mastlog.ldf |
| resource | mysqlsystemresource.mdf | mssqlsystemresource.ldf |
| model | model.mdf | modellog.ldf |
| msdb | msdbdata.mdf | msdblog.mdf |
| distribution | distmdl.mdf | distmdl.ldf |
| tempdb | tempdb.mdf | templog.ldf |
If you have not change the default install, the files are located in: C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data
Master database
The master database contains system wide information:
- Logins
- Linked servers
- Server configuration
- User database names and locations
- MSSQL will NOT start without the master database.
Resource database
The resource database contains all the system objects:
- System stored procedures
- System views
- You cannot see the resource database with the SQL Server Management Studio.
- You cannot see the resource database either with systems views or system procedures [ie: sp_helpdb].
Model database
The model database is a template that MSSQL uses to create the user databases. Meaning that each object you add to the model database will be replicated in each NEW user databases.
MSDB database
The msdb database stores the information for:
- SQL Server Agent
- Service Broker
- Log shipping
- Execution history
Distribution database
The distribution database is used for replication either as a replication server or a replication client.
- Replication metadata as a replication server or a replication client.
- Stores the actual transactions to be replicated.
Tempdb database
The tempdb database stores all the temporary data and all the temporary objects:
- Temporary tables. When the table name starts with # such as [ie: #abc], that table will be stored in tempdb.
- Temporary stored procedures. When the procedure name starts with # such as [ie: #abc], that procedure will be stored in tempdb.
- The tempdb file is emptied during the shutdown of the SQL Server.
- If the tempdb.mdf does not exist at startup, it will be recreated at the startup.
- Stores cursor data.
- Stores row versions when using row versioning or snapshot isolation.
- Store temporary during large sort, large indexing operation.

