
Answer-first summary for fast verification
Answer: `INSERT INTO my_table VALUES ('a1', 6, 9.4)`
## Explanation The correct answer is **A** because: 1. **`INSERT INTO my_table VALUES ('a1', 6, 9.4)`** is the standard SQL syntax for inserting new records into a table. This command appends the specified values as a new row to the existing Delta table. 2. **Why other options are incorrect:** - **B**: `my_table UNION VALUES ('a1', 6, 9.4)` - This is not valid SQL syntax for insertion. UNION is used to combine results of SELECT queries, not for inserting data. - **C**: `INSERT VALUES ('a1', 6, 9.4) INTO my_table` - This has incorrect syntax order. The correct order is `INSERT INTO table_name VALUES (...)`. - **D**: `UPDATE my_table VALUES ('a1', 6, 9.4)` - UPDATE is used to modify existing records, not to insert new ones. UPDATE requires a SET clause and WHERE condition. - **E**: `UPDATE VALUES ('a1', 6, 9.4) my_table` - This has multiple syntax errors: incorrect UPDATE syntax and wrong order. 3. **Additional context for Delta tables:** - When working with Delta tables in Databricks, standard SQL INSERT statements work seamlessly. - The INSERT INTO syntax is the correct way to append new records to an existing Delta table. - The VALUES clause must match the column order and data types of the target table. **Note:** The question assumes the table `my_table` has columns in the order: id, rank, rating, matching the data types specified in the record.
Author: Keng Suppaseth
Ultimate access to all questions.
A data engineer has been given a new record of data:
id STRING = 'a1'
rank INTEGER = 6
rating FLOAT = 9.4
id STRING = 'a1'
rank INTEGER = 6
rating FLOAT = 9.4
Which of the following SQL commands can be used to append the new record to an existing Delta table my_table?
A
INSERT INTO my_table VALUES ('a1', 6, 9.4)
B
my_table UNION VALUES ('a1', 6, 9.4)
C
INSERT VALUES ('a1', 6, 9.4) INTO my_table
D
UPDATE my_table VALUES ('a1', 6, 9.4)
E
UPDATE VALUES ('a1', 6, 9.4) my_table
No comments yet.