[英]How do I edit a unique column reference as foreign key in another table in mysql?
I have one master
table having column keywords varchar(120)
as Unique and it is reference to another table **cmp_keywords**
as a foreign key.我有一个
master
表,其中列keywords varchar(120)
作为 Unique 并且它引用另一个表**cmp_keywords**
作为外键。 Now how can I edit the column keywords
value from master
table and cmp_keywords
table?现在如何编辑
master
表和cmp_keywords
表中的列keywords
值?
Define your foreign key with the option ON UPDATE CASCADE
.使用选项
ON UPDATE CASCADE
定义外键。 Then just update the master table (correct term is parent table), then your child table will be updated automatically.然后只需更新主表(正确的术语是父表),然后您的子表将自动更新。
From the top of my head从我的头顶
ALTER TABLE cmp_keywords DROP FOREIGN KEY <foreign_key_name>,
ADD FOREIGN KEY my_new_fk_name (cmp_keywords_column) ON UPDATE CASCADE REFERENCES master_table(keywords);
should do it.应该这样做。 If not, figure out the correct syntax with this link .
如果没有,请使用此链接找出正确的语法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.