Teradata 数据库:是否可以使用唯一的复合键?
这是我第一次真正使用复合键。我有一条由三个外键列组成的记录。这三个键的组合必须是唯一的。如果插入重复记录,则应抛出约束错误,就像它是唯一的单字段主键一样。
这是针对 Teradata 数据库的。
This is my first time truly working with composite keys. I have a record that consists of three foreign key columns. The combination of these three keys must be unique. If a duplicate record is inserted, a constrain error should be thrown just as if it were a unique, single-field, primary key.
This is for Teradata database.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过表上的唯一二级索引来强制执行此操作。
如果包含
INDEX
作为替代访问方法没有好处,您还可以考虑在表上添加UNIQUE CONSTRAINT
。如果您计划在您的环境中实施 RI,Teradata 还支持使用主键约束约束。
You can enforce this via a unique secondary index on the table.
You could also consider adding a
UNIQUE CONSTRAINT
on the table as well if the inclusion of theINDEX
would not benefit as an alternative access method.Teradata also supports the use of Primary Key constraints if you are planning to enforce RI in your environment.