如何在MySQL中定义延迟约束 [英] How to define a deferred constraint in MySQL

查看:154
本文介绍了如何在MySQL中定义延迟约束的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在具有重复值的列上的现有表中创建主键?我想要以前的记录不通过验证,但是新记录将对此进行验证.在mysql中这是可能的.我知道在Oracle中是有可能的(这里是一个示例),但对mysql没有任何了解.

is it possible to create a primary key in a existing table on a column that have repeated value? I want is previous record not validate but new record will validate with this.Is it possible in mysql. I know it is possible in Oracle (here is an example) but don't have idea about mysql.

推荐答案

The link you posted as a comment to Nerd-Herd's answer uses deferred constraints. Those constraints are checked at the end of the transaction rather than at the time the statement is executed.

MySQL不支持延迟约束

如果您绝对需要延迟的约束并想要坚持使用开源数据库,则需要迁移到PostgreSQL.

If you absolutely need deferred constraints and want to stick with an open source database you will need to migrate to PostgreSQL.

这篇关于如何在MySQL中定义延迟约束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆