Mysql foreign key by non unique key — how is that possible?

后端 未结 4 1995
南笙
南笙 2021-01-12 08:50

I was migrating mysql database to postgres and stumbled across the following block in DDL (Note: This is what I got from mysqldump):

CREATE TABLE `catalog_pr         


        
4条回答
  •  情书的邮戳
    2021-01-12 09:41

    This weird behavior of FK's in innoDB is described in the manual.

    The handling of foreign key references to nonunique keys or keys that contain NULL values is not well defined for operations such as UPDATE or DELETE CASCADE. You are advised to use foreign keys that reference only UNIQUE and NOT NULL keys.

    PostgreSQL doesn't accept this construction, the foreign key has to point to a unique key.

提交回复
热议问题