Re: MySQL could not support bit storage?
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 yueliangdao0...@gmail.com 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? Any 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=arch...@jab.org
Re: MySQL could not support bit storage?
On Sun, May 10, 2009 at 10:12 PM, Moon's Father yueliangdao0...@gmail.com 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. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org
Re: MySQL could not support bit storage?
Thanks for your sincerely reply. On Mon, May 11, 2009 at 11:04 PM, Baron Schwartz ba...@xaprb.com wrote: On Sun, May 10, 2009 at 10:12 PM, Moon's Father yueliangdao0...@gmail.com 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