Solved

MYSQL equivilant for MSSQL Bit datatype

Posted on 2008-06-13
4
1,833 Views
Last Modified: 2008-06-27
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.
0
Comment
Question by:Prysson
  • 2
  • 2
4 Comments
 
LVL 76

Expert Comment

by:arnold
Comment Utility
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.



0
 

Author Comment

by:Prysson
Comment Utility
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
0
 
LVL 76

Expert Comment

by:arnold
Comment Utility
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.



0
 

Accepted Solution

by:
Prysson earned 0 total points
Comment Utility
Never mind. TinyInt(1) is what I am looking for.

0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Foreword In the years since this article was written, numerous hacking attacks have targeted password-protected web sites.  The storage of client passwords has become a subject of much discussion, some of it useful and some of it misguided.  Of cou…
Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now