This set of SQL Multiple Choice Questions & Answers (MCQs) focuses on “SQL Database”.
1. Which of the following does a database comprise of?
a) Collection of rows
b) Collection of tables
c) Collection of columns
d) Collection of data
View Answer
Explanation: A database is a collection of tables. A database contains more than one table that are linked directly or indirectly. A table can be termed as a collection of rows or columns containing useful information or data.
2. Which of the following command is used to create a database in SQL?
a) CREATE
b) MAKE
c) DEVELOP
d) INSERT
View Answer
Explanation: The CREATE command is used to create a database in SQL. The same command can be used to create a table within the database. The INSERT command is used to insert data inside the tables.
3. Which of the following syntax correctly represents the method to create a database in SQL?
a) Create Database
b) Create Database_name
c) Create Database Database_name
d) Create Database (Database_name)
View Answer
Explanation: The Syntax of creating a database in SQL is similar to the syntax of creating a table. Create command is used first, followed by the Database keyword and then the name of the database without any symbols in between.
4. Which of the following statement can be used to list all the databases in the SQL server?
a) Select name from master.sys.databases order by name
b) Select name from master.sys order by name
c) Select name from sys.databases order by name
d) Select name from master.databases order by name
View Answer
Explanation: The databases present in the SQL server can be listed using the statement – Select name from master.sys.databases order by name. Here, master.sys.databases means that the owner of the databases is calling all the databases in his system and order by clause is used to order the names according to the specified condition.
5. Which of the following command let us instruct the SQL server to check the existence of a database with a similar name before creating a database?
a) IF EXISTS
b) NOT EXISTS
c) IF NOT EXISTS
d) EXISTS
View Answer
Explanation: IF NOT EXISTS command helps us instruct the SQL server to check the existence of a database with a similar name before creating a database. It is helpful if you are working on a server that can be accessed by multiple people because there is a probability that there might be a database with a similar name that has been created by another person.
6. The “AS COPY OF” command is used to create a database as a copy of another source database.
a) True
b) False
View Answer
Explanation: The “AS COPY OF” command is used to create a database as a copy of another source database. It can be used as follows –
CREATE DATABASE database_name AS COPY OF source_database_name
Sanfoundry Global Education & Learning Series – SQL.
To practice all areas of SQL, 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]