MySQL - Unique foreign key

后端 未结 4 1754
走了就别回头了
走了就别回头了 2021-01-05 03:27

I have to make one of the foreign keys unique. The problem is, I am getting the following message from the phpMyAdmin:

The following indexes appear to be equal an         


        
4条回答
  •  逝去的感伤
    2021-01-05 03:56

    mysql > create unique index index_bar_id on foos(bar_id);
    mysql > alter table foos add constraint index_bar_id foreign key (bar_id) references bars (id);
    

    Read more at http://sixarm.com/about/mysql-create-indexes-foreign-keys-constraints.html

提交回复
热议问题