mysql - MySQL Workbench:如何将外键引用更改为与外表不同的字段?
问题描述
我有表 A,它使用外键(int)引用表 B。我希望表 A 中的所有条目都引用表 B 的name
字段(varchar)。如何对表 A 中的所有条目进行此更改?
每当我调出列名和数据类型的列表时,在“列”选项卡中将外键更改为 varchar 都会出现错误,而将外键更改为引用 B 的名称而不是 B 的 id 则会出现错误:
Create foreign key: Selected column Name must be indexed and be of a compatible type for a Foreign Key to be created
解决方案
推荐阅读
- sql-server - 使用 PowerShell 脚本创建具有混合模式身份验证的 SQL VM
- spring - Jdbc 模板和 Spring 的 keyHolder 的 Mockito 测试用例
- javascript - 将 React 组件转换为单个 js 文件以将其与空白 html 集成
- javascript - 反应:我对减速器的编辑状态有一些错误
- java - 微服务中的审计日志
- java - 输入日期 (MM/dd/yyyy) 到字符串
- java - 如何在 android studio 3.1.1 中引入默认的 pdf 开启器选项
- android - 我的应用程序中的 Viewpager Activity 重新启动
- liquibase - 如何在 Liquibase 中生成 SQL 执行日志
- sql - 如何在多维数据集中选择最大日期并存储在 plsql 存储过程的变量中