Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

MYSQL equivilant for MSSQL Bit datatype

Posted on 2008-06-13
4
Medium Priority
?
1,856 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL several years ago, it seemed like now was a good time to update it for object-oriented PHP.  This article does that, replacing as much as possible the pr…
Containers like Docker and Rocket are getting more popular every day. In my conversations with customers, they consistently ask what containers are and how they can use them in their environment. If you’re as curious as most people, read on. . .
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

730 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