cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

How can we alter table with auto increment column for a delta table

Bittu6084
New Contributor II

How can we alter table with auto increment column for a delta table

I have tried this but not working:

ALTER TABLE dbgtpTest.student ADD COLUMN Student_Id identity(100,1)

any Suggestions will be helpful

1 ACCEPTED SOLUTION

Accepted Solutions

Hubert-Dudek
Esteemed Contributor III

@Rakesh Reddy Badamโ€‹ , For ALTER ... ADD COLUMN in doc is only SYNC IDENTITY.

If you want to add an identity column to the existing table just create a new table with an identity column and then copy the data.

View solution in original post

6 REPLIES 6

-werners-
Esteemed Contributor III

@Rakesh Reddy Badamโ€‹ , I am not sure if that is supported. I only find references to creating an ID column with the CREATE TABLE statement.

Hubert-Dudek
Esteemed Contributor III

@Rakesh Reddy Badamโ€‹ , For ALTER ... ADD COLUMN in doc is only SYNC IDENTITY.

If you want to add an identity column to the existing table just create a new table with an identity column and then copy the data.

Kaniz_Fatma
Community Manager
Community Manager

Hi @Rakesh Reddy Badamโ€‹ , Just a friendly follow-up. Do you still need help, or @Hubert Dudek (Customer) and @Werner Stinckensโ€‹ 's response help you to find the solution? Please let us know.

Kaniz_Fatma
Community Manager
Community Manager

Hi @Bittu6084 (Customer)โ€‹ , Just a friendly follow-up. Do you still need help?

QPeiran
New Contributor III

Hi, I have the same concern. What's the best way to achieve this?

Hi @Peiran Quanโ€‹, This option is only supported for identity columns on Delta Lake tables.

Please read the article here.

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโ€™t want to miss the chance to attend and share knowledge.

If there isnโ€™t a group near you, start one and help create a community that brings people together.

Request a New Group