DATABRICKS-DATA-ANALYST-ASSOCIATE practice question 8 of 15

A data analyst has a managed table table_name in database database_name. They would now like to remove the table from the database and all of the data files associated with the table. The rest of the tables in the database must continue to exist. Which of the following commands can the analyst use to complete the task without producing an error?

Full set: 117 questions
Answer options
A: DROP DATABASE database_name;
B: DROP TABLE database_name.table_name; Correct answer
C: DELETE TABLE database_name.table_name;
D: DELETE TABLE table_name FROM database_name;
E: DROP TABLE table_name FROM database_name;
Correct Answer:
B. DROP TABLE database_name.table_name;
Explanation

The DROP TABLE command is the correct Data Definition Language (DDL) statement in Databricks SQL to remove a table's definition and its data. For a managed table, which is the default type, this command also deletes the underlying data files from their storage location. The syntax DROP TABLE databasename.tablename; uses a two-part identifier to precisely target the specific table within the specified database for removal, leaving all other tables in the database untouched. This directly and correctly accomplishes the task described.

Why Incorrect

A. DROP DATABASE databasename;: This command would delete the entire database, including all of its tables, which violates the requirement to preserve other tables.
C. DELETE TABLE databasename.tablename;: DELETE is a Data Manipulation Language (DML) command used to remove rows from a table, not the table object itself. The syntax DELETE TABLE is invalid.
D. DELETE TABLE tablename FROM databasename;: This is not valid SQL syntax for deleting a table. The DELETE command operates on rows within a table.
E. DROP TABLE tablename FROM databasename;: This is not valid SQL syntax. The DROP TABLE command does not use a FROM clause to specify the database.

References

1. Databricks SQL Documentation

DROP TABLE: The official documentation specifies the syntax for dropping a table as DROP TABLE [ IF EXISTS ] tablename. It clarifies that tablename can be a qualified name (e.g.

databasename.tablename). It also states

"When you drop a managed table

you also delete the underlying data."

Source: Databricks Documentation > SQL reference > Data definition language > DROP TABLE.

2. Databricks Documentation

What are tables on Databricks?: This document distinguishes between managed and external tables. It explicitly states for managed tables: "When you drop a managed table

the underlying data for this table is also deleted from your cloud tenant." This confirms that DROP TABLE on a managed table fulfills the requirement to remove the data files.

Source: Databricks Documentation > Data management > What are tables on Databricks? > Managed tables section.

3. Databricks Documentation

DROP DATABASE: This documentation shows that the DROP DATABASE command removes the database and all associated objects

including tables. This confirms why option A is incorrect as it does not isolate the deletion to a single table.

Source: Databricks Documentation > SQL reference > Data definition language > DROP DATABASE.

Scroll to Top