Create Delta Table in Databricks

Requirement

In our previous post, we have learned about Delta Lake and Delta Table in Databricks. In this post, we are going to create a Delta table with the schema.

Solution

For creating a Delta table, below is the template:

 CREATE TABLE <table_name> (
<column name> <data type>,
<column name> <data type>,
..)
USING DELTA;

Here, USING DELTA command will create the table as a Delta Table. It will have the underline data in the parquet format.

With the same template, let’s create a table for the below sample data:

Sample Data

empno

ename

designation

manager

hire_date

sal

deptno

location

9369

SMITH

CLERK

7902

12/17/1980

800

20

BANGALORE

9499

ALLEN

SALESMAN

7698

2/20/1981

1600

30

HYDERABAD

9521

WARD

SALESMAN

7698

2/22/1981

1250

30

PUNE

9566

TURNER

MANAGER

7839

4/2/1981

2975

20

MUMBAI

9654

MARTIN

SALESMAN

7698

9/28/1981

1250

30

CHENNAI

9369

SMITH

CLERK

7902

12/17/1980

800

20

KOLKATA

 CREATE TABLE employee_delta (
      empno INT,
      ename STRING,
      designation STRING,
      manager INT,
      hire_date DATE,
      sal BIGINT,
      deptno INT,
      location STRING
) USING DELTA;

Wrapping Up

In this post, we have learned how to create a delta table with the defined schema. Once the table gets created, you can perform insert, update using merge, delete data from the table. We will see all this exercise in coming posts.

Sharing is caring!

Subscribe to our newsletter
Loading

Leave a Reply