1

我正在尝试像我一直在做的那样对 Workbench 数据库进行正向工程。不过这次不同,它没有正常工作,而是给了我一个奇怪的错误。

Error Code: 1005. Can't create table '~~~~~~~~~~~~~~~~~~~' (errno: -1)

我尝试搜索 errno -1 是什么,但没有运气。任何人都知道此错误消息试图告诉我什么?

CREATE  TABLE IF NOT EXISTS `database`.`User` (

`Uid` MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT ,

`Username` VARCHAR(45) NOT NULL ,

`Password` TINYTEXT NOT NULL ,

`Avatar` TINYTEXT NULL ,

`Status` CHAR(6) NOT NULL DEFAULT 'Active' COMMENT 'Active, Warned, Banned' ,

 PRIMARY KEY (`Uid`) )

  ENGINE = InnoDB;

它还有其他部分,但它甚至无法通过任何表创建。还更改了数据库名称,很确定我拼写正确。

4

1 回答 1

3

我只是删除并在SQL Fiddledatabase.上运行您的查询,它可以工作:

CREATE  TABLE IF NOT EXISTS `User` (

`Uid` MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT ,

`Username` VARCHAR(45) NOT NULL ,

`Password` TINYTEXT NOT NULL ,

`Avatar` TINYTEXT NULL ,

`Status` CHAR(6) NOT NULL DEFAULT 'Active' COMMENT 'Active, Warned, Banned' ,

 PRIMARY KEY (`Uid`) )

  ENGINE = InnoDB;

看看InnoDB 错误代码,因为它说:

Error 1005 (ER_CANT_CREATE_TABLE)

Cannot create table. If the error message refers to error 150, table creation failed because a foreign key constraint was not correctly formed.
If the error message refers to error –1, table creation probably failed because the table includes a column name that matched the name of an internal InnoDB table. 
于 2013-03-01T08:04:07.847 回答