Basics Flashcards
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)
- Server configuration settings
- logon accounts
- linked servers information
- startup stored procedure
- file locations of user databases
When working with the master DB you should
Always have a current backup
Backup the master db ASAP after
- Creating, modifyinig, and dropping any databases
- Changing the server configurations
- Update the logon accounts
Basic Principles when using the master DB
- Always have a current backup
- backup the master DB after performing operations
- Do not create user objects in the master database
- Do not set the trustworthy database property of the master to on
Trustworthy Database property
SQL Server will trust the database and the contents within it which increase the security risk
msdb
- Used by the SQL Server Agent for scheduling jobs and alerts.
- stores the history of the SQL Agent jobs.
msdb supports
- Jobs & alerts
- database maile
- service broker
- the backup and restore history for the databases
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
- Property of a database
- Controls how SQL Server logs the transactions for the database
- Whether the transaction log of the database requires backing up
- What kind of restore operations are available for restoring the database
SQL Server provides you with three recovery models:
- Simple
- Full
- Bulk-logged
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
- SQL Server deletes transaction logs from the transaction log files at every checkpoint
- Transactions logs do not store the transaction records