Cit*_*zen 69 mysql sql mysql-error-1050 mysql-error-1146
我正在添加这个表:
CREATE TABLE contenttype (
contenttypeid INT UNSIGNED NOT NULL AUTO_INCREMENT,
class VARBINARY(50) NOT NULL,
packageid INT UNSIGNED NOT NULL,
canplace ENUM('0','1') NOT NULL DEFAULT '0',
cansearch ENUM('0','1') NOT NULL DEFAULT '0',
cantag ENUM('0','1') DEFAULT '0',
canattach ENUM('0','1') DEFAULT '0',
isaggregator ENUM('0', '1') NOT NULL DEFAULT '0',
PRIMARY KEY (contenttypeid),
UNIQUE KEY packageclass (packageid, class)
);
Run Code Online (Sandbox Code Playgroud)
我得到一个1050"桌子已经存在"
但该表不存在.有任何想法吗?
编辑:更多细节,因为每个人似乎都不相信我:)
DESCRIBE contenttype
Run Code Online (Sandbox Code Playgroud)
收益率:
1146 - 表'gunzfact_vbforumdb.contenttype'不存在
和
CREATE TABLE gunzfact_vbforumdb.contenttype(
contenttypeid INT UNSIGNED NOT NULL AUTO_INCREMENT ,
class VARBINARY( 50 ) NOT NULL ,
packageid INT UNSIGNED NOT NULL ,
canplace ENUM( '0', '1' ) NOT NULL DEFAULT '0',
cansearch ENUM( '0', '1' ) NOT NULL DEFAULT '0',
cantag ENUM( '0', '1' ) DEFAULT '0',
canattach ENUM( '0', '1' ) DEFAULT '0',
isaggregator ENUM( '0', '1' ) NOT NULL DEFAULT '0',
PRIMARY KEY ( contenttypeid ) ,
Run Code Online (Sandbox Code Playgroud)
产量:
1050 - 表'contenttype'已存在
Nul*_*ion 70
听起来你有Schroedinger的桌子 ......
说真的,你可能有一张破桌.尝试:
DROP TABLE IF EXISTS contenttypeREPAIR TABLE contenttype小智 32
来自MySQL日志:
InnoDB: You can drop the orphaned table inside InnoDB by
InnoDB: creating an InnoDB table with the same name in another
InnoDB: database and copying the .frm file to the current database.
InnoDB: Then MySQL thinks the table exists, and DROP TABLE will
InnoDB: succeed.
Run Code Online (Sandbox Code Playgroud)
Cra*_*ker 14
我得到了同样的错误,并且REPAIR TABLE(来自@ NullUserException的答案)没有帮助.
我终于找到这个解决方案:
sudo mysqladmin flush-tables
Run Code Online (Sandbox Code Playgroud)
对我来说,没有sudo,我得到以下错误:
mysqladmin: refresh failed; error: 'Access denied; you need the RELOAD privilege for this operation'
Run Code Online (Sandbox Code Playgroud)
(在OS X 10.6上运行)
小智 13
您可能需要刷新表缓存.例如:
DROP TABLE IF EXISTS `tablename` ;
FLUSH TABLES `tablename` ; /* or exclude `tablename` to flush all tables */
CREATE TABLE `tablename` ...
Run Code Online (Sandbox Code Playgroud)
创建视图时我也遇到了同样的问题。该视图较早出现,由于一些更改,它被删除了,但是当我尝试再次添加它时,它向我显示“视图已存在”错误消息。
解决方案:
您可以手动做一件事。
它将成功创建表。