
Explanation:
The correct command is CREATE DATABASE IF NOT EXISTS retail LOCATION ‘dbfs:/mnt/datalake/databases/retail‘; because it checks if the database already exists before attempting to create it, thus avoiding errors. The IF NOT EXISTS clause ensures that the command does nothing if the database is already present, while the LOCATION clause specifies where the database should be stored. This approach is both efficient and error-proof.
Ultimate access to all questions.
A data engineer is tasked with creating a database named 'retail' at the location 'dbfs:/mnt/datalake/databases/retail'. They are uncertain if the database already exists. Which command should they use to ensure the database is created without errors if it already exists?
A
CREATE DATABASE retail USING LOCATION ‘dbfs:/mnt/datalake/databases/retail‘;
B
CREATE DATABASE IF NOT EXISTS retail LOCATION ‘dbfs:/mnt/datalake/databases/retail‘;
C
CREATE DATABASE retail LOCATION ‘dbfs:/mnt/datalake/databases/retail‘;
D
CREATE DATABASE IF NOT EXISTS retail;
E
CREATE DATABASE retail DELTA LOCATION ‘dbfs:/mnt/datalake/databases/retail‘;
No comments yet.