MySQL could not support bit storage?

MySQL could not support bit storage?

am 11.05.2009 04:12:26 von yueliangdao0608

--0016363b88a67189060469998220
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

Hi.
MySQL only has one datatype called bit, but its smallest storage is one
byte.
How to save a bit on disk, but not a byte?
Any reply is appreciated.
--
David Yeung,
MySQL Senior Support Engineer,
Sun Gold Partner.
My Blog:http://yueliangdao0608.cublog.cn
Comanpy: http://www.actionsky.com

--0016363b88a67189060469998220--

Re: MySQL could not support bit storage?

am 11.05.2009 08:32:07 von Peter Chacko

Computer memory is not bit-addressable, how can you store a bit as an
independent data unit ?
Other than as part of a record, there are no C data types (which is
used to implement MySQL kernel) that can
process bit as a data type.

If i miss the context, please advise me back.
thanks

On Mon, May 11, 2009 at 7:42 AM, Moon's Father
wrote:
> =A0Hi.
> =A0 MySQL only has one datatype called bit, but its smallest storage is o=
ne
> byte.
> How to save a bit on disk, but not a byte?
> =A0Any reply is appreciated.
> --
> David Yeung,
> MySQL Senior Support Engineer,
> Sun Gold Partner.
> My Blog:http://yueliangdao0608.cublog.cn
> Comanpy: http://www.actionsky.com
>

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=3Dgcdmg-mysql-2@m.gmane.o rg

Re: MySQL could not support bit storage?

am 11.05.2009 17:04:19 von Baron Schwartz

On Sun, May 10, 2009 at 10:12 PM, Moon's Father
wrote:
> =A0Hi.
> =A0 MySQL only has one datatype called bit, but its smallest storage is o=
ne
> byte.
> How to save a bit on disk, but not a byte?

In some cases, CHAR(0) NULL can actually use one bit on disk. You
either store the empty string '', or you leave the column NULL. If it
is NULL, there is one bit in a bitmask that gets set. If it stores
the empty string, it uses no space, and the NULL bit is unset.

This is a stupid hack that is probably not a good idea in the general case.

Of course, the bitmap of NULL-ness is larger than one bit, so it makes
no sense to do this if there is only one such column in the table.
And in that case, you might be better off using an integer and packing
many bits together into it.

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=3Dgcdmg-mysql-2@m.gmane.o rg

Re: MySQL could not support bit storage?

am 12.05.2009 05:55:12 von yueliangdao0608

--0016e6475852d5403d0469af0f34
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

Thanks for your sincerely reply.

On Mon, May 11, 2009 at 11:04 PM, Baron Schwartz wrote:

> On Sun, May 10, 2009 at 10:12 PM, Moon's Father
> wrote:
> > Hi.
> > MySQL only has one datatype called bit, but its smallest storage is one
> > byte.
> > How to save a bit on disk, but not a byte?
>
> In some cases, CHAR(0) NULL can actually use one bit on disk. You
> either store the empty string '', or you leave the column NULL. If it
> is NULL, there is one bit in a bitmask that gets set. If it stores
> the empty string, it uses no space, and the NULL bit is unset.
>
> This is a stupid hack that is probably not a good idea in the general case.
>
> Of course, the bitmap of NULL-ness is larger than one bit, so it makes
> no sense to do this if there is only one such column in the table.
> And in that case, you might be better off using an integer and packing
> many bits together into it.
>



--
David Yeung,
MySQL Senior Support Engineer,
Sun Gold Partner.
My Blog:http://yueliangdao0608.cublog.cn
Comanpy: http://www.actionsky.com

--0016e6475852d5403d0469af0f34--