Solved

MYSQL equivilant for MSSQL Bit datatype

Posted on 2008-06-13
4
1,836 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 77

Expert Comment

by:arnold
ID: 21783879
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
ID: 21786872
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 77

Expert Comment

by:arnold
ID: 21786942
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
ID: 21787166
Never mind. TinyInt(1) is what I am looking for.

0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have been using r1soft Continuous Data Protection (http://www.r1soft.com/linux-cdp/) for many years now with the mySQL Addon and wanted to share a trick I have used several times. For those of us that don't have the luxury of using all transact…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

776 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