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