Microsoft Sql Server 2008 R2 System Databases
Posted
on DotNetBlocks
See other posts from DotNetBlocks
Published on Tue, 31 Dec 2013 01:01:00 -0400
Indexed on
2014/05/27
9:49 UTC
Read the original article
Hit count: 247
sql
For a majority of software developers little time is spent understanding the inner workings of the database management systems (DBMS) they use to store data for their applications. I personally place myself in this grouping. In my case, I have used various versions of Microsoft’s SQL Server (2000, 2005, and 2008 R2) and just recently learned how valuable they really are when I was preparing to deliver a lecture on "SQL Server 2008 R2, System Databases".
Microsoft Sql Server 2008 R2 System Databases
So what are system databases in MS SQL Server, and why should I know them? Microsoft uses system databases to support the SQL Server DBMS, much like a developer uses config files or database tables to support an application. These system databases individually provide specific functionality that allows MS SQL Server to function.
Name | Database File | Log File |
Master | master.mdf | mastlog.ldf |
Resource | mssqlsystemresource.mdf | mssqlsystemresource.ldf |
Model | model.mdf | modellog.ldf |
MSDB | msdbdata.mdf | msdblog.ldf |
Distribution | distmdl.mdf | distmdl.ldf |
TempDB | tempdb.mdf | templog.ldf |
Master Database
If you have used MS SQL Server then you should recognize the Master database especially if you used the SQL Server Management Studio (SSMS) to connect to a user created database. MS SQL Server requires the Master database in order for DBMS to start due to the information that it stores.
Examples of data stored in the Master database
- User Logins
- Linked Servers
- Configuration information
- Information on User Databases
Resource Database
Honestly, until recently I never knew this database even existed until I started to research SQL Server system databases. The reason for this is due largely to the fact that the resource database is hidden to users. In fact, the database files are stored within the Binn folder instead of the standard MS SQL Server database folder path. This database contains all system objects that can be accessed by all other databases. In short, this database contains all system views and store procedures that appear in all other user databases regarding system information. One of the many benefits to storing system views and store procedures in a single hidden database is the fact it improves upgrading a SQL Server database; not to mention that maintenance is decreased since only one code base has to be mainlined for all of the system views and procedures.
Model Database
The Model database as the name implies is the model for all new databases created by users. This allows for predefining default database objects for all new databases within a MS SQL Server instance. For example, if every database created by a user needs to have an “Audit” table when it is created then defining the “Audit” table in the model will guarantees that the table will be located in every new database create after the model is altered.
MSDB Database
The MSDBdatabase is used by SQL Server Agent, SQL Server Database Mail, SQL Server Service Broker, along with SQL Server. The SQL Server Agent uses this database to store job configurations and SQL job schedules along with SQL Alerts, and Operators. In addition, this database also stores all SQL job parameters along with each job’s execution history. Finally, this database is also used to store database backup and maintenance plans as well as details pertaining to SQL Log shipping if it is being used.
Distribution Database
The Distribution database is only used during replication and stores meta data and history information pertaining to the act of replication data. Furthermore, when transactional replication is used this database also stores information regarding each transaction. It is important to note that replication is not turned on by default in MS SQL Server and that the distribution database is hidden from SSMS.
Tempdb Database
The Tempdb as the name implies is used to store temporary data and data objects. Examples of this include temp tables and temp store procedures. It is important to note that when using this database all data and data objects are cleared from this database when SQL Server restarts. This database is also used by SQL Server when it is performing some internal operations. Typically, SQL Server uses this database for the purpose of large sort and index operations.
Finally, this database is used to store row versions if row versioning or snapsot isolation transactions are being used by SQL Server.
Additionally, I would love to hear from others about their experiences using system databases, tables, and objects in a real world environments.
© DotNetBlocks or respective owner