This set of SQL Multiple Choice Questions & Answers (MCQs) focuses on “SQL Drop Table”.
1. Which of the following command is used to delete the structure of a table in SQL?
a) DELETE
b) DROP
c) ERASE
d) TRUNCATE
View Answer
Explanation: The DROP command is used to delete the structure of a table in SQL. The same command can be used to delete a database. The DELETE command is used to delete the specific information present inside the table. The TRUNCATE command is used to delete complete data from the table.
2. In SQL, the DROP command can be put under which of the following category?
a) DDL (Data Definition Language)
b) DML (Data Manipulation Language)
c) DCL (Data Control Language)
d) TCL (Transaction Control Language)
View Answer
Explanation: In SQL, the DROP command comes under the category of DDL (Data Definition Language) that is used to define the structure of the table. DML (Data Manipulation Language) is used to manipulate the data inside the table. DCL (Data Control Language) is used by the database administrator to configure security access to relational databases. TCL (Transaction Control Language) is used to commit or rollback the changes made by DML commands.
3. Which of the following statement is used to delete a table in SQL?
a) DROP TABLE
b) DROP table_name
c) DROP TABLEtable_name
d) DROP TABLE (table_name)
View Answer
Explanation: The syntax which is used to delete a database in SQL is –
DROP TABLEtable_name
In this statement DROP and TABLE are keywords that remain the same for every statement using the DROP command, while table_name is the specific name of the table which has to be dropped and varies from statement to statement. The same syntax is used when using the DROP command for deleting a database.
4. Which of the following statement is used to drop multiple tables at once in SQL?
a) DROP TABLE table_name1&table_name2&…table_namen;
b) DROP TABLE table_name1, table_name2,…table_namen;
c) DROP table_name1, table_name2,…table_namen;
d) DROP TABLE table_name1 table_name2 …. table_namen;
View Answer
Explanation: The syntax for dropping multiple tables at once in SQL is –
DROP TABLE table_name1, table_name2,…table_namen;
Multiple table names are just separated by a comma (,).
5. In SQL, which of the following statement is used to conditionally drop a table that already exists?
a) DROP TABLE IF EXISTS table_name
b) DROP TABLE IF NOT EXISTS table_name
c) DROP TABLE EXISTS table_name
d) DROP TABLE NOT EXISTS table_name
View Answer
Explanation: The IF EXISTS command is used with the DROP command to conditionally drop a table only if it already exists in the SQL Server. If we try to drop a table that is not present, SQL will give us an error. To prevent an error from occurring we can use the IF EXISTS option.
6. The DROP command cannot be used to drop a table that is referenced by a FOREIGN KEY constraint.
a) True
b) False
View Answer
Explanation: The DROP command cannot be used to drop a table that is referenced by a FOREIGN KEY constraint. The referencing FOREIGN KEY constraint or the referencing table must first be dropped otherwise the system will return an error.
7. Which of the following statement is used to drop a table present in another database?
a) DROP TABLE table_name.dbo.database_name
b) DROP TABLE database_name.table_name
c) DROP TABLE table_name.database_name
d) DROP TABLE database_name.dbo.table_name
View Answer
Explanation: DROP TABLE database_name.dbo.table_name is the statement used to drop a table that is present in another database. Here, dbo stands for database owner. After executing the statement, it drops the specified table in the specified database.
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]