What are different System Databases available in SQL Server? Explain their uses.
SQL Server mainly contains four System Databases (master,model,msdb,tempdb). Each of them is used by SQL Server for Separate purposes. From all the databases, master database is the most important database.
Master Database
Master Database contains information about SQL server configuration. Without Master database, server can’t be started. This will store the metadata information about all other objects(Databases,Stored Procedure,Tables,Views,etc.) which is Created in the SQL Server .
It will contain login information of users.
If the master database gets corrupted and is not recoverable from the backup, then a user has to again rebuild the master database. Therefore, it is always recommended to maintain a current backup of the master database. As everything crucial to SQL server is stored in the master database, it cannot be deleted as it is the heart of SQL SERVER
Even it is possible to create user objects in master database, it is not recommended to do so. The master database should stay as static as possible. For example, in the case that master database being rebuilt, all user objects will be lost.
Model Database
The model database sets a template for every database that was newly created . It serves as a template for the SQL server in order to create a new database. When we create a new database, the data present in model database are moved to new database to create its default objects which include tables, stored procedures, etc. Primarily, the requirement of model database is not specific to creation of new database only. Whenever the SQL server starts, the Tempdb is created by using model database in the form of a template. By default it does not contain any data.
Msdb
The msdb database is used mainly by the SQL server Management Studio, SQL Server Agent to store system activities like sql server jobs, mail, service broker, maintenance plans, user and system database backup history, Replication information, log shipping .We need to take a backup of this database for the proper function of SQL Server Agent Service.
TempDB
From the name of the database itself, we can identify the purpose of this database. It can be accessed by all the users in the SQL Server Instance.
The tempdb is a temporary location for storing temporary tables(Global and Local) and temporary stored procedure that hold intermediate results during the sorting or query processing and cursors.
If more temporary objects are created and used storage of tempDB then performance of SQL Server will affect.So recommened to move the temdb to the location where sufficient amount of space is there.
This Database will be created by SQL Server instance when the SQL Server service starts. This database is created using model database.We cannot take a backup of temp Database.
Ref:
https://www.sqlshack.com/sql-server-system-databases-the-master-database/
https://www.mssqltips.com/sqlservertip/1420/sql-server-system-databases/
Post a Comment
0 Comments