Skip to main content

Add Primary Keys

When set to Y, adds primary key constraints to generated CREATE TABLE scripts for Delta tables.

When enabled, the table create scripts declare the table's key: the key columns are altered with SET NOT NULL and a PRIMARY KEY constraint is added with ALTER TABLE ... ADD CONSTRAINT, replacing any existing primary key. On history-bearing tables the effective-from date column is included in the key. When a Constraint Mode other than DoNotCreate is also configured for the layer, matching FOREIGN KEY constraints are added for the modeled table references.

When to Change This Setting

Keep the default Y to carry the model's key definitions into the Databricks catalog, where they describe the table relationships to consumers and tooling. Disable it when the target workspace does not accept the constraint DDL or you prefer tables without declared keys.

SettingInteraction
Constraint Mode DVEnables the foreign key constraints for Data Vault references
Constraint Mode DMThe equivalent control for Data Mart references
Constraint Mode STGThe equivalent control for Staging references
Use Liquid ClusteringClusters the table by the same key columns

Notes

  • This setting is part of the Databricks settings category.
  • The default value for this setting is Y.