假设我们有四个表
员工、employee_history、employee_details、emp_details_history
employee_history 是员工的重复项 emp_details_history 应该是employee_details 的重复
人们没有引用emp_details_history中的employee_history,而是引用了员工表并创建了列并且也具有值。
现在我想更改employee_details_history的外键列名称以指向employee_history而不是emp_details。
employee_details_history 具有列 pkey 和 employee_id(而不是 pkey 和 employee_history_id)
系统不允许删除历史表中引用的员工记录。历史不同,实际记载应该不同。
现在想要指向正确的列和名称。
您能帮我看看如何更改外键列和名称吗?
提前致谢。
最佳答案
1. To remove foreign key constraints
go to phpmyadmin
select prefered table
select structure
click relational view link under the structure
change the Foreign key constraint of needed columns
2. to change column names
go to phpmyadmin
select prefered table
select structure
click change link of preferred column
change the column name
如果您想作为查询来更改列名称,请尝试此操作 Error renaming a column in MySQL
如果你想删除外键试试这个 MySQL Removing Some Foreign keys
希望这有帮助
关于mysql - 将外键和名称更新为新的相似表列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35476292/