
Answer-first summary for fast verification
Answer: `INSERT INTO my_table VALUES ('a1', 6, 9.4)`
## Explanation **Correct Answer: A** **Why Option A is correct:** - `INSERT INTO table_name VALUES (...)` is the standard SQL syntax for inserting new records into a table. - The syntax correctly specifies the table name (`my_table`) and provides the values in the correct order matching the table's column structure. - This command will append the new record to the existing Delta table. **Why other options are incorrect:** **Option B:** `my_table UNION VALUES ('a1', 6, 9.4)` - This is not valid SQL syntax for inserting data. UNION is used to combine results of SELECT statements, not for inserting data. - Even if used with SELECT, it would create a new result set but not modify the table. **Option C:** `INSERT VALUES ('a1', 6, 9.4) INTO my_table` - This has incorrect syntax. The correct order is `INSERT INTO table_name VALUES (...)`. - Some database systems might support this syntax, but it's not standard SQL and not guaranteed to work in Databricks/Spark SQL. **Option D:** `UPDATE my_table VALUES ('a1', 6, 9.4)` - UPDATE is used to modify existing records, not to insert new ones. - The syntax is incorrect for UPDATE statements, which require SET clause to specify column updates. **Option E:** `UPDATE VALUES ('a1', 6, 9.4) my_table` - This is completely invalid SQL syntax for any operation. - UPDATE statements require a SET clause and typically a WHERE clause to identify which rows to update. **Key Learning Points:** 1. Use `INSERT INTO table_name VALUES (...)` to append new records to a table. 2. Ensure the values are provided in the correct order matching the table's column definitions. 3. UPDATE is for modifying existing records, not for inserting new ones. 4. Always use standard SQL syntax for compatibility across different SQL implementations.
Author: Keng Suppaseth
Ultimate access to all questions.
No comments yet.
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