Solved

MYSQL equivilant for MSSQL Bit datatype

Posted on 2008-06-13
4
1,849 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 79

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 79

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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

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…
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

623 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