简体   繁体   中英

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.

There's one particular table, Users, that is subject to the usual set of steps:

  1. a CREATE command,
  2. an INSERT INTO command, then
  3. an ALTER TABLE command that adds constraints (foreign keys).

The script was generated by exporting from MySQL itself. The error occurs at the final step, ie ALTER TABLE. The error message says that the Users table already exists (which of course it does).

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.

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

EDIT 2: Here's the error message

*ERROR 1050 (42S01) at line 7736 in file...

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. (Lesson learned).

The ALTER TABLE command was adding 2 identical constraints.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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