#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Location
    kerala, India
    Posts
    81
    Rep Power
    2

    Which datatype is used for checkbox


    Hi,

    I am building my 1st MySQL database and have 1 question:

    1) If I want to have a checkbox linked to a field in a table, what Data Type do I set for that field?

    Thanks and Regards
    Sarath
  2. #2
  3. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,280
    Rep Power
    4279
    i would use CHAR(1) because it's portable to other database systems (i.e. it's non-proprietary, unlike, say, ENUM)
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Sep 2006
    Posts
    2,042
    Rep Power
    535
    Originally Posted by r937
    unlike, say, ENUM
    Yikes, the spawn of the devil!

    If the checkbox is yes/no, what about tinyint?
  6. #4
  7. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,280
    Rep Power
    4279
    TINYINT is okay, except it isn't quite as portable as CHAR
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

IMN logo majestic logo threadwatch logo seochat tools logo