SQL Server Questions and Answers – Database Snapshots

This set of SQL Server Multiple Choice Questions & Answers (MCQs) focuses on “Database Snapshots”.

1. Which of the syntax is used for creating database snapshot in SQL Server?
a)

CREATE Snapshot database_snapshot_name
    ON
    (
        NAME = logical_file_name,
        FILENAME = 'os_file_name'
    )

b)

CREATE DATABASESNAPSHOT database_snapshot_name
    ON
    (
        NAME = logical_file_name,
        FILENAME = 'os_file_name'
    )

c)

advertisement
advertisement
CREATE DATABASE database_snapshot_name
    ON
    (
        NAME = logical_file_name,
        FILENAME = 'os_file_name'
    )

d) None of the mentioned
View Answer

Answer: c
Explanation: Creating a snapshot requires specifying the logical name of every database file of the source database.

Note: Join free Sanfoundry classes at Telegram or Youtube

2. Point out the correct statement.
a) Snapshots can be used in conjunction with database mirroring for reporting purposes
b) A snapshot is write-only, static view of a database
c) A snapshot is read-only, dynamic view of a database
d) None of the mentioned
View Answer

Answer: a
Explanation: You can create a database snapshots on the mirror database and direct client connection requests to the most recent snapshot.

advertisement

3. Which of the following scenario prefers not to use database snapshots?
a) Database Snapshots should be seen as high availability option
b) Database Snapshots should not be seen as an alternative to regular backups of your data
c) Snapshots can be created very quickly
d) All of the mentioned
View Answer

Answer: b
Explanation: Database snapshots can not protect your databases against disk errors or database corruption.

4. Which of the following code will DROP an existing snapshot before creating new?
a)

advertisement
IF NOT EXISTS(
    SELECT 
        * 
    FROM 
        sys.databases 
    WHERE 
        name = 'DatabaseA_Snapshot' 
    AND source_database_id IS NOT NULL
    )
BEGIN
    CREATE DATABASE [DatabaseA_Snapshot] 
    ON (NAME=DatabaseA, FileName='<whatever>') 
    AS SNAPSHOT OF [DatabaseA]
END

b)

IF EXISTS(
    SELECT 
        * 
    FROM 
        sys.databases 
    WHERE 
        name = 'DatabaseA_Snapshot' 
    AND source_database_id IS NOT NULL
    )
BEGIN
    CREATE DATABASE [DatabaseA_Snapshot] 
    ON (NAME=DatabaseA, FileName='<whatever>') 
    AS SNAPSHOT OF [DatabaseA]
END

c)

IF NOT EXISTS(
    SELECT 
        * 
    FROM 
        system.databases 
    WHERE 
        name = 'DatabaseA_Snapshot' 
    AND source_database_id IS NOT NULL
    )
BEGIN
    CREATE DATABASE [DatabaseA_Snapshot] 
    ON (NAME=DatabaseA, FileName='<whatever>') 
    AS SNAPSHOT OF [DatabaseA]
END

d) None of the mentioned
View Answer

Answer: a
Explanation: A snapshot database always have an entry in sys.databases.source_database_id.

5. Point out the wrong statement.
a) You cannot used SQL Server Management Studio for creating a database snapshots
b) Snapshots have to be created using T-SQL
c) All recovery models support database snapshot
d) A database can have one and only one snapshot
View Answer

Answer: d
Explanation: A database can have multiple snapshots.

6. Which of the following code will throw error?
a)

CREATE DATABASE AWDB_Snapshot_20080522 ON (
NAME = master,
FILENAME = 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\AWDB_Snapshot.ss')
AS SNAPSHOT OF master;

b)

CREATE DATABASE AWDB_Snapshot_2008 ON (
NAME = AdventureWorks_Data,
FILENAME = 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\AWDB_Snapshot.ss')
AS SNAPSHOT OF AdventureWorks;

c)

CREATE DATABASE AWDB_Snapshot_20080 ON (
NAME = AdventureWorks_Data,
FILENAME = 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\AWDB_Snapshot.ss')
AS SNAPSHOT OF AdventureWorks;

d)

CREATE DATABASE Snapshot_20080522 ON (
NAME = Adventure,
FILENAME = 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\AWDB_Snapshot.ss')
AS SNAPSHOT OF Adventure;
View Answer
Answer: a
Explanation: Snapshot of master database should be created explicitly using SSMS.
 
 

7. To revert the database, which of the following Transact-SQL statement is used?
a) RESTORE Snapshot <database_name> FROM DATABASE_SNAPSHOT = <database_snapshot_name>
b) RESTORE DATABASE <database_name> FROM DATABASE_SNAPSHOT = <database_snapshot_name>
c) REST DATABASE <database_name> FROM DATABASE_SNAPSHOT = <database_snapshot_name>
d) None of the mentioned
View Answer

Answer: b
Explanation: Back up the reverted database, especially if it uses the full (or bulk-logged) recovery model.

8. Which of the following message comes when you try to update or delete the data snapshot?
a) Row Deletion
b) The row was committed
c) Row has been updated
d) Failed to update the database
View Answer

Answer: c
Explanation: You will receive a read only message because snapshots have read-only tables.

9. Syntax for creating database snapshot in SQL Server is _______________
a) DROP DATABASE [snapshottest];
b) DELETE DATABASE [snapshottest];
c) DROP Snapshot [snapshottest];
d) None of the mentioned
View Answer

Answer: a
Explanation: We drop the snapshot database like any other database using drop database command.

10. What should be done to check to see if data still exists in the Snapshot?
a) Run Delete on Database Snapshot
b) Run Update on Database Snapshot
c) Run Select on Database Snapshot
d) Run Insert on Database Snapshot
View Answer

Answer: c
Explanation: You can run the same SELECT statement on the database snapshot. Here you can see that all of the data which we have deleted in the source database still exists. This is what we will recover using the database snapshot.

Sanfoundry Global Education & Learning Series – SQL Server.

To practice all areas of SQL Server, here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.