By default, SQL Server provides you with four main systems databases:
1.master
2.msdb
3.model
4. tempdb
The master database stores (General)
all the system-level information of an SQL Server instance
The master database stores (Specific)
When working with the master DB you should
Always have a current backup
Backup the master db ASAP after
Basic Principles when using the master DB
Trustworthy Database property
SQL Server will trust the database and the contents within it which increase the security risk
msdb
msdb supports
model db
template for creating other databases
tempdb
Stores temporary user objects that you explicitly create like temporary tables and table variables
Can you backup or restore the tempdb?
No, SQL Server recreates the tempdb every time it starts
SQL Server Recovery Model
SQL Server provides you with three recovery models:
To view the recovery model of the HR database, you use the following query:
SELECT
name,
recovery_model_desc
FROM master.sys.databases
WHERE name = ‘HR’;
To change the recovery model to another
ALTER DATABASE database_name
SET RECOVERY recovery_model
In the SIMPLE recovery model
FULL recovery model
SQL Server keeps the transaction logs in the transaction log files until the BACKUP LOG statement is executed
FULL recoverty model allows you to
Restore the database at any point in time
BULK_LOGGED recovery model
What is a Backup
A backup is an image of that database at the time of the full backup
Backup Types
To restore the database you need
A full backup
How to perform a full backup
BACKUP DATABASE database_name
TO DISK = path_to_backup_file;