【发布时间】:2017-11-13 15:19:18
【问题描述】:
在数据库术语中,当我添加一个新的外键,为该外键插入一条记录并更新现有记录时,这个过程叫什么?我的目标是能够更有效地找到答案。
//create temporary linking key
alter table example add column example_foreign_key int unsigned null;
//contains more fields
insert into example_referenced_table (example_id, ...)
select id, ...
from example
join ...;
//link with the table
update example join example_referenced_table on example_id = example.id
set example.example_foreign_key = example_referenced_table.id;
//drop linking key
alter table example_referenced_table drop column example_id;
【问题讨论】:
-
为什么投反对票?
标签: mysql relational-database terminology