Search code examples
mysqldatabaseflags

Which datatype for flag?


Which datatype should I use for a flag (in MySQL)? I just want to check if a user is online at the moment.
I thought about a TINYINT or SET which both could be 0 or 1.


Solution

  • TINYINT is perfect for what you are suggesting:

    `status` tinyint(1) unsigned NOT NULL DEFAULT '0'