简体   繁体   English

MySql错误-表已存在

[英]MySql Error - Table already exists

I have a large SQL script that I use for creating test data and I'm getting an error message that doesn't make any sense. 我有一个用于创建测试数据的大型SQL脚本,但收到一条毫无意义的错误消息。

There's one particular table, Users, that is subject to the usual set of steps: 有一个特定的表“用户”,该表遵循通常的步骤:

  1. a CREATE command, 一个CREATE命令,
  2. an INSERT INTO command, then INSERT INTO命令,然后
  3. an ALTER TABLE command that adds constraints (foreign keys). 一个添加约束(外键)的ALTER TABLE命令。

The script was generated by exporting from MySQL itself. 该脚本是通过从MySQL本身导出而生成的。 The error occurs at the final step, ie ALTER TABLE. 错误发生在最后一步,即ALTER TABLE。 The error message says that the Users table already exists (which of course it does). 该错误消息表明Users表已经存在(当然可以)。

I'm not sure when this error crept in. Over the last few days my Ubuntu did a partial upgrade (yes, I know, big mistake), and also the test data has changed a few times. 我不确定何时会出现此错误。在过去的几天中,我的Ubuntu进行了部分升级(是的,我知道,是个大错误),并且测试数据也已更改了几次。

I tried deleting and recreating the database, but that didn't help. 我尝试删除并重新创建数据库,但这没有帮助。 Any ideas? 有任何想法吗?

EDIT: The MySQL version is 5.5.32-0ubuntu0.12.04.1 编辑:MySQL版本是5.5.32-0ubuntu0.12.04.1

EDIT 2: Here's the error message 编辑2:这是错误信息

*ERROR 1050 (42S01) at line 7736 in file... *文件中7736行的错误1050(42S01)错误1050 ...

OK, so in cutting/pasting the SQL commands to add them to the question above (in response to the many comments and downvotes), I found the problem. 好的,因此在剪切/粘贴SQL命令以将它们添加到上面的问题中(以响应许多注释和降票),我发现了问题。 (Lesson learned). (学过的知识)。

The ALTER TABLE command was adding 2 identical constraints. ALTER TABLE命令添加了两个相同的约束。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM