
Answer-first summary for fast verification
Answer: `CREATE DATABASE IF NOT EXISTS customer360 LOCATION '/customer/customer360';`
## Explanation The correct answer is **C** because: 1. **`IF NOT EXISTS` clause**: This is essential since the data engineer is unsure if the database already exists. Without this clause, running the command would fail with an error if the database already exists. 2. **`LOCATION` specification**: The requirement explicitly states the database should be created at the location `/customer/customer360`. This needs to be included in the command. 3. **Syntax correctness**: The syntax `CREATE DATABASE IF NOT EXISTS database_name LOCATION 'path'` is the correct Spark SQL syntax for creating a database with a specific location if it doesn't already exist. **Why other options are incorrect:** - **A**: Missing `IF NOT EXISTS` clause - would fail if database already exists - **B**: Missing `LOCATION` specification - would create database at default location, not at `/customer/customer360` - **D**: Incorrect syntax - `DELTA` keyword is not valid in `CREATE DATABASE` statement - **E**: Missing `IF NOT EXISTS` clause and has incorrect `DELTA` keyword - would fail if database exists and has invalid syntax This question tests knowledge of Spark SQL DDL commands for database creation with conditional execution and custom location specification.
Author: Keng Suppaseth
Ultimate access to all questions.
A data engineer needs to create a database called customer360 at the location /customer/customer360. The data engineer is unsure if one of their colleagues has already created the database.
Which of the following commands should the data engineer run to complete this task?
A
CREATE DATABASE customer360 LOCATION '/customer/customer360';
B
CREATE DATABASE IF NOT EXISTS customer360;
C
CREATE DATABASE IF NOT EXISTS customer360 LOCATION '/customer/customer360';
D
CREATE DATABASE IF NOT EXISTS customer360 DELTA LOCATION '/customer/customer360';
E
CREATE DATABASE customer360 DELTA LOCATION '/customer/customer360';
No comments yet.