cancel
Showing results for 
Search instead for 
Did you mean: 
Get Started Discussions
Start your journey with Databricks by joining discussions on getting started guides, tutorials, and introductory topics. Connect with beginners and experts alike to kickstart your Databricks experience.
cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to create table with primary key

mano7438
New Contributor III

Hi Team,

Getting below error while creating a table with primary key,

"Table constraints are only supported in Unity Catalog."

Table script : 

CREATE TABLE persons(first_name STRING NOT NULL, last_name STRING NOT NULL, nickname STRING,CONSTRAINT persons_pk PRIMARY KEY(first_name, last_name));

1 ACCEPTED SOLUTION

Accepted Solutions

mano7438
New Contributor III

Hi @Debayan ,

Yes enabled . Its working now. I am able to create table with primary key. 

View solution in original post

6 REPLIES 6

Debayan
Databricks Employee
Databricks Employee

Hi, primary key is not supported outside Unity Catalog. 

Please refer: https://docs.databricks.com/en/tables/constraints.html#declare-primary-key-and-foreign-key-relations...

Please let us know if this helps, also, please tag @Debayan with your next comment which will notify me. Thanks!

mano7438
New Contributor III

HI @Debayan 

I am creating inside unity catalog only because I have enabled unity catalog for my workspace. 

Debayan
Databricks Employee
Databricks Employee

Hi, this needs further investigation, could you please raise a support case with Databricks? 

mano7438
New Contributor III

Hi @Debayan ,

I have enabled unity catalog for my SQL warehouse like below, Could you please verify, is this correct way of enabling unity catalog or am doing anything wrong. It will be good if u will provide correct steps for enabling unity catalog for workspace

Please find the attached screen shot

mano7438_0-1692945766429.pngmano7438_1-1692945796409.png

 

 

 

 

Debayan
Databricks Employee
Databricks Employee

mano7438
New Contributor III

Hi @Debayan ,

Yes enabled . Its working now. I am able to create table with primary key. 

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