Link to home
Start Free TrialLog in
Avatar of Prysson
Prysson

asked on

MYSQL equivilant for MSSQL Bit datatype

In my MSSQL a boolean field is a bit datatype

Havign done a migration of a MSSQL database into MySQL all my Bit values have been converted to TinyInt(4) value that dont accept a bool variables value in an insert statement.

Looking at MySQL datatypes I note that there are Bit, TinyInty(1) and Boolean  datatypes....(When I select Boolean and apply the changes to the table it changes the value to TinyInt(1))

Is Boolean the correct type to use for a boolean value (true, false)  in MySQL...is Bit interchangable with Boolean?  What is teh correct datatype to use in MySQL if i am trying to store Boolean data values.
Avatar of arnold
arnold
Flag of United States of America image

true=1
false=0

TRUE and FALSE are define in mysql as 1 and 0.  Make sure not to enclose them as string values i.e.'true','false' during inserts.



Avatar of Prysson
Prysson

ASKER

I guess what I am asking is shoudl MySql datatype be TinyInt(1)  or Bit  to accomodate the need for a Boolean datatype.

Based on my reading either would do..I understand that MySQL has atomatic alias of True False t0 1 and zero  for the TinyInt(1)  but that Bit is more efficient...so I am wondering if

1. Does Bit also do autmatic translation of boolean value to 0 and 1
2. If Bit is more efficient why would you use TinyInt(1)
3. Is there some advantage to using Boolean (TinyInt(1)) versus Bit
What efficiency are you talking about storage? the bit type defined columns seem to require the use of the b'' prefix to identify the data being entered as a bit format.
i.e. b'1' is not the same as 1.



ASKER CERTIFIED SOLUTION
Avatar of Prysson
Prysson

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial