Tinyint vs Bit?

前端 未结 16 2066
暖寄归人
暖寄归人 2020-12-13 05:13

I don\'t want to touch-off a religious war here, but there seem to be two schools of thoughts in how to represent boolean values in a database. Some say bit is

16条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-13 06:11

    When you add a bit column to your table it will occupy a whole byte in each record, not just a single bit. When you add a second bit column it will be stored in the same byte. The ninth bit column will require a second byte of storage. Tables with 1 bit column will not gain any storage benefit.

    Tinyint and bit can both be made to work, I have used both successfully and have no strong preference.

提交回复
热议问题