[英]Adding Primary and Foreign keys to SQL Table on Databricks
I'm new to Databricks and when I want to alter my SQL tables by adding primary or FK, I get an absurd error that can't seem to debug it.我是 Databricks 的新手,当我想通过添加主要或 FK 来更改我的 SQL 表时,我收到一个似乎无法调试的荒谬错误。
%sql
ALTER TABLE samples_abp215dsdp ADD CONSTRAINT PRIMARY (SampleID);
here is the error message:这是错误消息:
Error in SQL statement: ParseException:
mismatched input '(' expecting {'CHECK', 'FOREIGN', 'PRIMARY', 'UNIQUE'}(line 1, pos 55)
== SQL ==
ALTER TABLE samples_abp215dsdp ADD CONSTRAINT PRIMARY (SampleID)
------------------------------------------------------^^^
any help will be appreciated.任何帮助将不胜感激。
spark do not have any concept of primary key. spark没有任何主键的概念。 As spark is computation engine not database.由于 spark 是计算引擎而不是数据库。
There are new features coming in 2022 . 2022 年将推出新功能。 Follow below list:请遵循以下列表:
In 2023 : 2023 年:
Primary Key and Foreign Key are now available on Databricks: https://docs.databricks.com/spark/latest/spark-sql/language-manual/sql-ref-syntax-ddl-create-table-constraint.html主键和外键现在可在 Databricks 上使用: https://docs.databricks.com/spark/latest/spark-sql/language-manual/sql-ref-syntax-ddl-create-table-constraint.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.