Error Creating Primary Key Constraint
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2023 03:23 AM
I am trying to add a primary key constraint to an existing table, and I get the following error;
Cannot create or update table because the child column(s) `my_primary_key` of primary key `pk` cannot be set to nullable. Either drop the constraint, or change the column nullability.
This doesn't make sense to me... why would you want a primary key column to be nullable? In any event, I tried to alter the column to allow nulls and still got the same error.
I appreciate that primary keys and foreign keys in data bricks are informational only, but I want to be able to support downstream BI developers with this information if possible.
- Labels:
-
Primary Key Constraint
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2023 05:18 AM
Hi, Could you please confirm if you are using the latest databricks-sql-connector ? (https://pypi.org/project/databricks-sql-connector/)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2023 07:35 PM
I'm not using databricks-sql-connector. I ran the query from the query editor within databricks itself.

