
Answer-first summary for fast verification
Answer: CREATE OR REPLACE TABLE table_name ( employeeId STRING, startDate DATE, avgRating FLOAT )
The correct option is A because the 'CREATE OR REPLACE TABLE' command will create a new table or replace an existing table with the specified schema. This ensures that the table is empty and has the required columns 'employeeId STRING, startDate DATE, avgRating FLOAT'. Option B uses an invalid SQL syntax with 'WITH COLUMNS', Option C does not guarantee an empty table if the table already exists, and Option D is incorrect because 'CREATE TABLE AS SELECT' is used for creating a table with data from an existing query, not for specifying an empty table.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
As part of the project to create a comprehensive employee performance tracking system, a data architect has specified the need for a new table designed to store employee ratings over time. The required schema for this table is as follows: ( employeeId STRING, startDate DATE, avgRating FLOAT ).
Which code block, using a SQL Data Definition Language (DDL) command, would you utilize to create an empty Delta table with the aforementioned schema? The solution should ensure that the table is created even if a table with the same name already exists, without causing errors due to existing table conflicts.
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
No comments yet.