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
Esteemed Contributor III
Esteemed Contributor III

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
Esteemed Contributor III
Esteemed Contributor III

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
Esteemed Contributor III
Esteemed Contributor III

mano7438
New Contributor III

Hi @Debayan ,

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

Join 100K+ Data Experts: Register Now & Grow with Us!

Excited to expand your horizons with us? Click here to Register and begin your journey to success!

Already a member? Login and join your local regional user group! If there isn’t one near you, fill out this form and we’ll create one for you to join!