CertKeen

Databricks Data Engineer Associate · Free practice question 11 of 12

ALTER TABLE ADD COLUMNS on Delta

The team at Carlow Marine needs to add a nullable column vessel_class of type STRING to the existing Delta table fleet.silver.vessels without rewriting existing data. Which statement does this?

  1. A.CREATE OR REPLACE TABLE fleet.silver.vessels (vessel_class STRING)
  2. B.INSERT INTO fleet.silver.vessels (vessel_class) VALUES (NULL)
  3. C.UPDATE fleet.silver.vessels SET vessel_class = NULL
  4. D.ALTER TABLE fleet.silver.vessels ADD COLUMNS (vessel_class STRING)
Show answer and explanation

Correct answer: D. ALTER TABLE fleet.silver.vessels ADD COLUMNS (vessel_class STRING)

Why: ALTER TABLE ... ADD COLUMNS adds new columns to a Delta table as a metadata change, and existing rows return NULL for the new column. CREATE OR REPLACE with a single column would replace the table definition and its data. INSERT and UPDATE cannot reference a column that does not yet exist.

More free Databricks Data Engineer Associate questions