0

I came to know that MySQL Workbench allows a BIN flag on a column for storing data as binary strings here.

If that's the case, what's the difference between BIN flag and the datatype BINARY(n)? Besides, it even allows me to set this flag on columns with datatypes VARCHAR(n), CHAR(n), etc. which seems to be conflicting.

When should I exactly use this flag?

Community
  • 1
  • 1
Nikunj Madhogaria
  • 2,139
  • 2
  • 23
  • 40
  • Is your question when to use `binary` or what? If it's about using MySQL workbench then it's offtopic since it's not about a programming problem. – N.B. Aug 18 '15 at 14:43
  • No. It's not about when to use `binary`. I need to know the difference between the *flag* and the *datatype*. Why need flag when we have a datatype? – Nikunj Madhogaria Aug 18 '15 at 14:45
  • I see, well the bin flat and character data types seem to be mutually exclusive. The flag is probably to tell you extras about the column (unique, primary key etc). However, why and how those flags work exactly - that's something what Workbench dev will have to answer. Also, since your question is about a tool and not programming problem, we're slightly offtopic here. – N.B. Aug 18 '15 at 14:50
  • You got a Workbench dev in your contacts list? :P I would beg to differ. The designing part plays a role in the future programming. Besides, why would SO allow a `mysql-workbench` tag in my question with over 2.2k questions? – Nikunj Madhogaria Aug 18 '15 at 14:55
  • Your question is about a tool and what something means in that tool. I don't see how that can be a programming problem. Also, it's not that hard to email people who maintain MySQL Workbench. What I'm saying is that you haven't presented a programming problem - that means you are not likely to get an answer to your question. You obviously found a logical bug in the program - why are mutually exclusive data type and "flag" able to "work" together. I agree it's intriguing question, but it's definitely better to ask on [this forum](http://forums.mysql.com/list.php?152). – N.B. Aug 18 '15 at 14:59
  • I'll drink to that. Still I think it's worth putting up the question here. People might get into a similar confusion in future. Hopefully, we'll have an answer for them here on SO. :) – Nikunj Madhogaria Aug 18 '15 at 15:02
  • 1
    I won't vote to close, I do agree with you :) – N.B. Aug 18 '15 at 15:03

1 Answers1

1

You can see the manual entry here. The most obvious use for this is where you have an ID rather than text where you may want an ID of, say, "A107652B" to be distinct from "a107652b". Most textual types would treat these as the same.

Giles
  • 1,597
  • 11
  • 15
  • I think you misunderstood my question. I understand the meaning of `BINARY` datatype. I want to know: How does the `BIN` *flag* differ from `BINARY` *datatype* ? If the flag serves any purpose for some reason, shouldn't be it allowed only on columns with `BINARY` datatype? – Nikunj Madhogaria Aug 18 '15 at 14:43
  • Ah, my apologies - in terms of storage and how mysql treats the data under the hood, no, there is no difference. Using the Bin flag on a char/varchar column is a convenience for humans however as it allows us to enter data into, and view data in, that column using strings rather than having to use numbers. – Giles Aug 18 '15 at 14:49