
Ultimate access to all questions.
A data architect has determined that a table of the following format is necessary:
employeeId startDate avgRating
a1 2009-01-06 5.5
a2 2018-11-21 7.1
...
employeeId startDate avgRating
a1 2009-01-06 5.5
a2 2018-11-21 7.1
...
Which code block is used by SQL DDL command to create an empty Delta table in the above format regardless of whether a table already exists with this name?
A
CREATE OR REPLACE TABLE table_name ( employeeId STRING, startDate DATE, avgRating FLOAT )
B
CREATE OR REPLACE TABLE table_name WITH COLUMNS ( employeeId STRING, startDate DATE, avgRating FLOAT ) USING DELTA
C
CREATE TABLE IF NOT EXISTS table_name ( employeeId STRING, startDate DATE, avgRating FLOAT )
D
CREATE TABLE table_name AS SELECT employeeId STRING, startDate DATE, avgRating FLOAT
Explanation:
Option A is correct because:
CREATE OR REPLACE TABLE creates a new table or replaces an existing one with the same nameWhy other options are incorrect:
WITH COLUMNS and USING DELTA - this is not valid SQL DDL syntaxCREATE TABLE IF NOT EXISTS only creates the table if it doesn't exist, which doesn't match the requirement to create it regardless of existing tableCREATE TABLE ... AS SELECT which requires data from a query, not just column definitions, and doesn't handle table replacementKey Points:
CREATE OR REPLACE TABLE is the standard way to ensure a table exists with specified schema