views:

142

answers:

3

I'm adding this table:

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)
);

And I get a 1050 "table already exists"

But the table does NOT exist. Any ideas?

EDIT: more details because everyone seems to not believe me :)

DESCRIBE contenttype

yields:

1146 - Table 'gunzfact_vbforumdb.contenttype' doesn't exist

and

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 ) ,

Yields:

1050 - Table 'contenttype' already exists

+1  A: 

First check if you are in the right database USE yourDB and try Select * from contenttype just to see what is it and if it exists really...

laurent-rpnet
Definitely the right db, check my edited info above.
Citizen
+2  A: 

Sounds like you have Schroedinger's table... LOL.

Seriously now, you probably have a broken table. Try:

  • DROP TABLE IF EXISTS contenttype
  • REPAIR TABLE contenttype
  • If you have sufficient permissions, delete the data files (in /mysql/data/db_name)
NullUserException
> REPAIR TABLE contenttype USE_FRMyieldsgunzfact_vbforumdb.contenttype repair Error Can't open tablegunzfact_vbforumdb.contenttype repair status Operation failedSo we're getting closer but still no resolution. I dont know if the data is necessary in the table, is there any other way to fix it? I ran a myisamchk with no luck as well.
Citizen
Can access *.myi, *.myd, *.frm files for the tables?
NullUserException
I'm not sure what you mean
Citizen
@Citizen Those are the actual files where table data and structure information are stored. They are usually somewhere in the mysql dir.
NullUserException
Just a heads up to anyone else, the table did exist but was totally borked. Nothing would detect it but I could drop the table.
Citizen
+1  A: 

I had the same problem at Mac OS X and MySQL 5.1.40. I used eclipse to edit my SQL script and than I tried MySQLWorkbench 5.2.28. Probably it converted newline characters to Mac format. I had no idea about what's wrong with my script until I commented out the first line in file. After this this script was interpreted by mysql as a one single comment. I used build-in TextEdit Mac application to fix this. After line-breaks was converted to the correct format, the error 1050 gone.

Update for Eclipse users:

To set up default ending for new files created, across the entire workspace:

Window -> Preferences -> General -> Workspace -> New text file line delimiter.

To convert existing files, open file for editing and for the currently edited file, go to the menu:

File -> Convert Line Delimiters To

Antonio