栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

SQL

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

SQL

错误121表示存在外键约束错误。由于您使用的是InnoDB,因此您可以

SHOW ENGINE INNODBSTATUS
在运行失败的查询后使用,以在本
LATEST FOREIGN KEY ERROR
节中获得解释。我自己运行了SQL,我得到了:

------------------------LATEST FOREIGN KEY ERROR------------------------101210 14:55:50 Error in foreign key constraint creation for table `regula`.`Reservation`.A foreign key constraint of name `regula`.`prjId`already exists. (Note that internally InnoDB adds 'databasename'in front of the user-defined constraint name.)Note that InnoDB's FOREIGN KEY system tables storeconstraint names as case-insensitive, with theMySQL standard latin1_swedish_ci collation. If youcreate tables or databases whose names differ only inthe character case, then collisions in constraintnames can occur. Workaround: name your constraintsexplicitly with unique names.

基本上,您需要在最后一个表中给prjId约束名称一个唯一的名称。约束/外键名称是数据库的全局名称,因此不能在不同的表中重复使用。只需更改最后一个

  ConSTRAINT `prjId`

  ConSTRAINT `prjId2`


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/381898.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号