Basics Flashcards

1
Q

By default, SQL Server provides you with four main systems databases:

A

1.master
2.msdb
3.model
4. tempdb

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

The master database stores (General)

A

all the system-level information of an SQL Server instance

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

The master database stores (Specific)

A
  1. Server configuration settings
  2. logon accounts
  3. linked servers information
  4. startup stored procedure
  5. file locations of user databases
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

When working with the master DB you should

A

Always have a current backup

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Backup the master db ASAP after

A
  1. Creating, modifyinig, and dropping any databases
  2. Changing the server configurations
  3. Update the logon accounts
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Basic Principles when using the master DB

A
  1. Always have a current backup
  2. backup the master DB after performing operations
  3. Do not create user objects in the master database
  4. Do not set the trustworthy database property of the master to on
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Trustworthy Database property

A

SQL Server will trust the database and the contents within it which increase the security risk

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

msdb

A
  1. Used by the SQL Server Agent for scheduling jobs and alerts.
  2. stores the history of the SQL Agent jobs.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

msdb supports

A
  1. Jobs & alerts
  2. database maile
  3. service broker
  4. the backup and restore history for the databases
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

model db

A

template for creating other databases

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

tempdb

A

Stores temporary user objects that you explicitly create like temporary tables and table variables

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Can you backup or restore the tempdb?

A

No, SQL Server recreates the tempdb every time it starts

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

SQL Server Recovery Model

A
  1. Property of a database
  2. Controls how SQL Server logs the transactions for the database
  3. Whether the transaction log of the database requires backing up
  4. What kind of restore operations are available for restoring the database
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

SQL Server provides you with three recovery models:

A
  1. Simple
  2. Full
  3. Bulk-logged
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

To view the recovery model of the HR database, you use the following query:

A

SELECT
name,
recovery_model_desc
FROM master.sys.databases
WHERE name = ‘HR’;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

To change the recovery model to another

A

ALTER DATABASE database_name
SET RECOVERY recovery_model

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

In the SIMPLE recovery model

A
  1. SQL Server deletes transaction logs from the transaction log files at every checkpoint
  2. Transactions logs do not store the transaction records
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

FULL recovery model

A

SQL Server keeps the transaction logs in the transaction log files until the BACKUP LOG statement is executed

19
Q

FULL recoverty model allows you to

A

Restore the database at any point in time

20
Q

BULK_LOGGED recovery model

A
  1. Similar to full recovery model
  2. Does not allow you to restore the database at any point in time
  3. Allows you to BULK INSERT flat files into tables are described briefly in the transaction log files
21
Q

What is a Backup

A

A backup is an image of that database at the time of the full backup

22
Q

Backup Types

A
  1. Full Backup
  2. Differential Backup
  3. Transaction log backup
23
Q

To restore the database you need

A

A full backup

24
Q

How to perform a full backup

A

BACKUP DATABASE database_name
TO DISK = path_to_backup_file;

25
Q

Differential Backup

A

Contains only data that has been modified since the last full backup

26
Q

Transaction log backup

A

Contains all changes made to the database

27
Q

Before creating a user that accesses the databases in a SQL Server

A
  1. Create a login for SQL Server
  2. Create a user and map the user with the login
28
Q

Create Login SQL

A

CREATE LOGIN login_name
WITH PASSWORD = password;

29
Q

Create User SQL

A

CREATE USER username
FOR LOGIN login_name;

30
Q

A Securable

A

is a resource to which the SQL Server authorization system regulates access.

ex. a table is a securable

31
Q

A principal

A

is an entity that can request the SQL Server resource

ex. a user is a principal in SQL Server

32
Q

GRANT basic SQL Syntax

A

GRANT permissions
ON securable TO principal;

33
Q

REVOKE basic SQL Syntax

A

REVOKE permissions
ON securable
FROM principal;

34
Q

Roles

A

A group of permissions

35
Q

3 main role types

A
  1. Server-level roles
  2. Database-level roles
  3. Application-level roles
36
Q

Server-level Roles

A

Manage the permissions on SQL Server-like changing server configuration

37
Q

Database-level roles

A

Manage the permissions on databases like creating tables and querying data

38
Q

Application-level roles

A

Allow an application to run with its own, user-like permissions

39
Q

For each type of role there are two types

A
  1. Fixed server roles
  2. User-defined roles
40
Q

Fixed server roles

A

The built roles provided by SQL Server. These roles have a fixed set of permissions

41
Q

User-defined roles

A

The roles you define to meet specific security requirements

42
Q

db_datareader

A

Allows all members to read data from all user tables and views in the database

43
Q
A