SQL Server System databases

 

Types of system databases

Introduction

Each time you install any SQL Server instance on a server, by default/automatically 4 primary system databases are created.

  • master
  • model
  • msdb
  • tempdb

  

Master database

It is a critical database, because SQL Server uses this database to store all the information about SQL Server instance, like

·        File location of the user database -> If you create any user database all the information and configuration details

·        Login accounts

·        Server configuration setting

·        Link Servers information

·        Start-up stored procedures

If for any reason, master database is not accessible or doesn’t exist or can not be read then the SQL Server instance can not start.

It’s important to backup the master database whenever there is a configuration change, logins creation and etc.

Model database

SQL Server uses the model database as a template to create new user defined databases.

Note:

Creating a user’ objects in the model database is not suggested/recommended unless there is a business requirement, because every new database that will be created will have those objects as well, that means new user defined databases get everything from the model database.

Additionally, tempdb is also created by using the model database as a template every time the server restarts. So, any object created in template database will exists in temp database also.

Msdb database

This database is another critical database, It is also known as “the SQL server Agent database” because it stores information about all the SQL Agent jobs like their configuration details and execution history.

Functionality of the msdb database:

·        Support SQL Server Agent

·        History for SQL Server Agent

·        Database Mail

·        Service Broker

·        Backup and restore history for the databases

It is required to backup whenever any changes at the SQL Server Agent level and other changes.

Temp database

It is one of important system database, the name itself indicates it is used to store temporary user objects, like temporary tables that are defined by the users using prefix of # or ## then those are created in the tempdb database.

·        Tempdb is a shared resource and used by all the SQL Server database users  

·        Tempdb is used for temporary objects, worktables, online index operations, cursors and many other

·        It is recreated every time the server is restarted

·        As this is a temporary storage (non-permanent) so no option or it’s doesn’t allow to backup the database.

·        It’s a workforce for SQL Server databases

Below image shows that no backup option available when we select “Task” option in the tempdb:



Resource database:

 It is a read-only database that contains all the system objects that are included with SQL Server. The system objects like sys.objects, are physically stored in the resource objects, but they are logically listed in the sys schema of every database.

The resource database doesn’t contain user data or metadata information.

Benefit of Resource database:

In earlier versions of SQL Server, upgrading requires dropping and creating system objects. Now, it’s does not require to drop and recreate the system objects as the resource database file contains all system objects so the upgrade can be accomplished by just copying the single resource database file to the local server. This way the resource database makes upgrading to a new version of SQL Server an easier and faster procedure.

sys object’s location:

 

Resource database location:



Comments

Popular posts from this blog

Auditing in Oracle database

rs.stepDown() in MongoDB replication

Tuples in Python