[SOLVED] MySQL - create table containing a BOOLEAN fails???

Discussion in 'Plugin Development' started by Gabriel333, Nov 4, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    Gabriel333

    Hi

    Im trying to create a table with some BOOLEAN's in, but I make something wrong, can anybody tell me why my sqlstatement is failing?

    Code:
    query = "CREATE TABLE Book (bookid INT, title TEXT, author TEXT, coauthors TEXT,  numberofpages INT, pageno INT, bodytext TEXT, mastercopy BOOLEAN, mastercopyid INT, force BOOLEAN, moved BOOLEAN, copy BOOLEAN, usecost INT);";
    this is the error:

    Code:
    2011-11-03 14:34:43 [INFO] [BukkitInventoryTools] Permissions3/SuperpermBridge is detected. Permissions v2.7.2
    2011-11-03 14:34:43 [INFO] [BukkitInventoryTools] Spout is detected.
    2011-11-03 14:34:43 [INFO] [BukkitInventoryTools] MySQL Initializing
    2011-11-03 14:34:43 [INFO] [BukkitInventoryTools] MySQL connection successful
    2011-11-03 14:34:43 [INFO] [BukkitInventoryTools] Creating table BukkitInventoryTools5
    2011-11-03 14:34:43 [INFO] [BukkitInventoryTools] Creating table Bookshelf
    2011-11-03 14:34:43 [INFO] [BukkitInventoryTools] Creating table Book
    
    2011-11-03 14:34:43 [SEVERE] [BukkitInventoryTools]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'force BOOLEAN, moved BOOLEAN, copy BOOLEAN, usecost INT)' at line 1
    
    2011-11-03 14:34:44 [INFO] [BukkitInventoryTools] BIT version 2.7.5 is enabled!
    2011-11-03 14:34:44 [INFO] [BukkitInventoryTools] Register enabled: iConomy v5).
     
  2. You can't use keywords as column names. I can't exactly remember, but one or more of 'force', 'moved' and 'copy' are keywords and thus lead to a syntax error.
    Rename them to something unique.

    Also, shouldn't "title", "author" and "coauthors" rather be VARCHARs than TEXTs? They don't exactly need to contain that huge values.
     
  3. Offline

    Gabriel333

    Thanks. I didn't know that one of them was a keyword. I will dig in to this, thanks!!!

    I think I will clean up in the names and datatypes today... :)
     
  4. It's not important but BOOLEAN is just a synonym for TINYINT(1) :p
     
Thread Status:
Not open for further replies.

Share This Page