List:General Discussion« Previous MessageNext Message »
From:Dan Nelson Date:January 25 2002 5:32pm
Subject:Re: MySQL Checkbox table field
View as plain text  
In the last episode (Jan 25), Michael Collins said:
> At 10:49 AM -0600 1/25/02, Dan Nelson wrote:
> > > >Which field type do I use for a simply checkbox Y,N?
> 
> >The BIT type seems to be the best fit.  It's currently a synonym for
> >CHAR(1), but there's a TODO item:
> >
> >   * Optimise `BIT' type to take 1 bit (now `BIT' takes 1 char).
> 
> Are you thinking MS SQL Server? I am not sure there is a bit type in 
> MySQL? Do you mean Char(0)? Anyhow, in MS SQL Server a bit type 
> column cannot be indexed so you are better off with CHAR(1).

Why would the MySQL TODO mention an MS SQL feature? :)

mysql> create table test ( myfield bit primary key );
Query OK, 0 rows affected (0.01 sec)

mysql> desc test;
+---------+------------+------+-----+---------+-------+
| Field   | Type       | Null | Key | Default | Extra |
+---------+------------+------+-----+---------+-------+
| myfield | tinyint(1) |      | PRI | 0       |       |
+---------+------------+------+-----+---------+-------+
1 row in set (0.88 sec)

OK, so it's actually a synonym for tinyint(1).

-- 
	Dan Nelson
	dnelson@stripped
Thread
Re: MySQL Checkbox table fieldVernon A Webb25 Jan
Re: MySQL Checkbox table fieldMichael Collins25 Jan
  • Re: MySQL Checkbox table fieldDan Nelson25 Jan
    • Re: MySQL Checkbox table fieldMichael Collins25 Jan
      • Re: MySQL Checkbox table fieldDan Nelson25 Jan
        • Re: MySQL Checkbox table fieldMichael Collins25 Jan
          • Re: MySQL Checkbox table fieldDan Nelson25 Jan
            • Re: MySQL Checkbox table fieldMichael Collins25 Jan
RE: MySQL Checkbox table fieldTodd Williamsen25 Jan
RE: MySQL Checkbox table fieldJames E. Hicks III25 Jan
RE: MySQL Checkbox table fieldMatthew Walker25 Jan
  • RE: MySQL Checkbox table fieldPaul DuBois25 Jan
Re: MySQL Checkbox table fieldDavid Shields25 Jan
RE: MySQL Checkbox table fieldMatthew Walker25 Jan
  • RE: MySQL Checkbox table fieldPaul DuBois25 Jan