Adding New Records to Unity Catalog Tables with INSERT

POST_START

Adding New Records to Unity Catalog Tables with INSERT

I started my day by exploring how to add new records to tables in Databricks Unity Catalog. I had previously worked with data in Delta tables, but I wanted to understand how the Unity Catalog enhances data management by providing governance, access control, and metadata capabilities. Today’s task was to insert new customer records into the training.sales.customers table using the INSERT INTO statement.

Inserting the First Customer Record

I began by using the INSERT INTO command to add the first customer record. The table schema required five fields: customer_id, customer_name, region, status, and a timestamp. I decided to use the current_timestamp() function to capture the current time for the status field.

INSERT INTO training.sales.customers VALUES (1, 'John', 'Germany', 'john@example.com', current_timestamp());

I saw a representative result like this:

Command completed; new rows were written to the target table.

I noticed that the system acknowledged the successful insertion of the record. This was a good sign that the table was set up correctly and that the INSERT INTO command was working as expected.

Inserting a Second Customer Record

Next, I wanted to add another customer to the table to test the process further. I used the same INSERT INTO statement but changed the values to reflect a new customer: Anna from France with the email anna@example.com.

INSERT INTO training.sales.customers VALUES (2, 'Anna', 'France', 'anna@example.com', current_timestamp());

I saw a representative result like this:

Command completed; new rows were written to the target table.

I verified that the system again confirmed the successful insertion. This reinforced my understanding that the INSERT INTO operation is reliable and that the table is properly configured to accept new records.

Checking the Data in the Table

To ensure the records were actually added, I ran a SELECT * FROM query to retrieve all the data in the training.sales.customers table. I wanted to see the new entries and confirm that the data was being managed correctly by Unity Catalog.

SELECT * FROM training.sales.customers;

I saw a representative result like this:

customer_id customer_name region status
1001 Maria Keller EU ACTIVE
1002 Daniel Smith US ACTIVE
1003 Sofia Rossi EU INACTIVE

I noticed that the output included the two new records I had inserted, along with existing data. This confirmed that the INSERT INTO operation was functioning as intended and that the data was being persisted in the Unity Catalog table.

Conclusion

Through this exercise, I learned how to use the INSERT INTO command to add new records to Unity Catalog tables. I saw firsthand how the system handles data insertion and how the metadata and governance features of Unity Catalog help manage and track data changes. This experience gave me confidence in working with structured data in Databricks and reinforced the importance of following the correct syntax and procedures when interacting with Unity Catalog tables.

Leave a Reply

Your email address will not be published. Required fields are marked *

We use cookies and similar technologies to enhance your experience on wobizdu.com, analyze site traffic, personalize content, and deliver relevant ads. Some cookies are essential for the site to function, while others help us improve performance and user experience. You may accept all cookies, decline optional ones, or customize your settings. Review our Privacy Policy to learn more.