sql - Tinyint vs Bit -


I do not want to touch a religious war here, but it seems how the idea of ​​two schools is in a database of Boolean values Some people say that bit is the appropriate data type, while others argue that tinint is better.

The only difference I know is this:

  • bit : storage size is 1 bit, possible value 0 or 1
  • Tint : storage size is 1 byte, possible value 0-255

Which data types are better for you to represent Boolean values? What is the tint for the extra upper part value? Do you need prices?

When you add a bit column to your table, it will capture a whole byte in each record Not just a bit. When you add a second bit column, it will be stored in the same byte. The ninth bite column will require a second byte of storage. Tables with 1-bit columns will not get any storage benefit.

Tinants and bits can be done to work both, I have used both successfully and there is no strong preference.


Comments