
Answer-first summary for fast verification
Answer: CREATE OR REPLACE TABLE students( id STRING, name STRING, dateOfBirth DATE, email STRING)
The correct answer is `CREATE OR REPLACE TABLE students(...)`. This command will create the table if it doesn't exist or replace it if it does, which is exactly what's needed. The other options either don't handle the case where the table already exists (`CREATE TABLE...`), use invalid syntax (`CREATE OR REPLACE TABLE IF EXISTS...`), or incorrectly attempt to create the table by selecting data from another source (`CREATE OR REPLACE TABLE...AS SELECT...`). The default table type in Databricks is Delta, so specifying `USING DELTA` is optional.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
No comments yet.
A data engineer needs to create an empty Delta table named students with specific columns, regardless of whether a table with this name already exists. Which SQL DDL command should they use?
A
CREATE TABLE IF NOT EXISTS students( id STRING, name STRING, dateOfBirth DATE, email STRING)
B
CREATE OR REPLACE TABLE students( id STRING, name STRING, dateOfBirth DATE, email STRING)
C
CREATE TABLE students( id STRING, name STRING, dateOfBirth DATE, email STRING)
D
CREATE OR REPLACE TABLE IF EXISTS students( id STRING, name STRING, dateOfBirth DATE, email STRING)
E
CREATE OR REPLACE TABLE students AS SELECT id STRING, name STRING, dateOfBirth DATE, email STRING USING DELTA