Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 9 of 9
  1. #1
    WDF Staff Wired's Avatar
    Join Date
    Apr 2003
    Posts
    7,656
    Member #
    1234
    Liked
    137 times
    I'm trying to create a boolean field in mySQL and it keeps giving me errors for unknown reasons. Anyone know why?

    CREATE TABLE `tbleStuff` (
    `StuffID` int(5) NOT NULL auto_increment,
    `NameofStuff` varchar(10) default NULL,
    `On_Off` boolean (1) default `0`,
    PRIMARY KEY (`StuffID`)
    ) TYPE=MyISAM;

    Any idea why it won't work? It looks valid to me. Enum woudln't work either.
    The Rules
    Was another WDF member's post helpful? Click the like button below the post.

    Admin at houseofhelp.com

  2.  

  3. #2
    Senior Member nsr81's Avatar
    Join Date
    Oct 2002
    Posts
    1,132
    Member #
    250
    Liked
    15 times
    don't think you need to add length/size parameter when using "BOOL" or "BOOLEAN". They are synonym for "Tinyint(1)".
    There and Back Again :Ogre:

  4. #3
    WDF Staff Wired's Avatar
    Join Date
    Apr 2003
    Posts
    7,656
    Member #
    1234
    Liked
    137 times
    `On_Off` boolean (1),
    `On_Off` boolean,
    nada.

    `On_Off` tinyint(1),
    worked though. I'd love to default it in the database as 0 though, but it won't let me.
    The Rules
    Was another WDF member's post helpful? Click the like button below the post.

    Admin at houseofhelp.com

  5. #4
    Senior Member nsr81's Avatar
    Join Date
    Oct 2002
    Posts
    1,132
    Member #
    250
    Liked
    15 times
    Code:
    CREATE TABLE `tableStuff` (
    `StuffID` INT( 5 ) NOT NULL AUTO_INCREMENT,
    `NameofStuff` VARCHAR( 10 ) ,
    `On_Off` TINYINT( 1 ) DEFAULT '0' NOT NULL ,
    PRIMARY KEY ( `StuffID` ) 
    ) TYPE = MYISAM ;
    I'm running an older version of PMA (2.4.0), it won't give me Bool or Boolean option.
    There and Back Again :Ogre:

  6. #5
    WDF Staff Wired's Avatar
    Join Date
    Apr 2003
    Posts
    7,656
    Member #
    1234
    Liked
    137 times
    your code worked fine, but mine won't... W T F

    Here's the exact code sans name changes:
    CREATE TABLE `tbleTYUIOP` (
    `qwe` int( 10 ) NOT NULL auto_increment ,
    `asd` varchar( 50 ) NOT NULL ,
    `zxc` varchar( 255 ) NOT NULL ,
    `rty` tinyint( 1 ) default `0` NOT NULL ,
    PRIMARY KEY ( `qwe` )
    ) TYPE=MyISAM;
    The Rules
    Was another WDF member's post helpful? Click the like button below the post.

    Admin at houseofhelp.com

  7. #6
    Senior Member zionlocke's Avatar
    Join Date
    Jan 2003
    Location
    .: l33t Basement :.
    Posts
    736
    Member #
    483
    Liked
    3 times
    you have:
    default `0` NOT NULL

    he had:
    DEFAULT '0' NOT NULL
    Cheers, zionlocke :chinese:
    Links: Zion Creation | Blog

  8. #7
    Senior Member nsr81's Avatar
    Join Date
    Oct 2002
    Posts
    1,132
    Member #
    250
    Liked
    15 times
    LOL backtick isn't that useful afterall
    There and Back Again :Ogre:

  9. #8
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    You should always use default sizes on datatypes, with the exception of chars or varchars (the defaults are usually fastest).

    As with using booleans... i'm pretty sure that int(4) - the default int - is faster.

  10. #9
    WDF Staff Wired's Avatar
    Join Date
    Apr 2003
    Posts
    7,656
    Member #
    1234
    Liked
    137 times
    Zionlocke, the ticks don't change the error, and caps don't matter at all.

    Transio, u sure about that, int(4) is faster? As for datatypes, looking through some other professionaly done tables, none of them are at defaults.
    The Rules
    Was another WDF member's post helpful? Click the like button below the post.

    Admin at houseofhelp.com


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 03:47 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com