Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There isn't a difference.</p> <p>However, there is a caveat if you're storing a string. </p> <p>If you only want to store a byte array or other binary data such as a stream or file then use the binary type as that is what they are meant for.</p> <p>Quote from the <a href="http://dev.mysql.com/doc/refman/5.0/en/charset-binary-op.html" rel="nofollow">MySQL manual</a>:</p> <blockquote> <p>The use of CHARACTER SET binary in the definition of a CHAR, VARCHAR, or TEXT column causes the column to be treated as a binary data type. For example, the following pairs of definitions are equivalent: </p> <pre><code>CHAR(10) CHARACTER SET binary BINARY(10) VARCHAR(10) CHARACTER SET binary VARBINARY(10) TEXT CHARACTER SET binary BLOB </code></pre> </blockquote> <p>So, technically there is no difference.</p> <p>However, when storing a string it must be converted from a string to byte values using a character set. The decision is to either do this yourself before the MySQL server or you leave it up to MySQL do to do for you. MySQL will perform with by casting a string to BINARY using the BIN character sets.</p> <p>If you want to store the encoding in another format, lets say you have a business requirement that says you must use 4 bytes per character (MySQL doesn't do this by default) you could then use the "CHARACTER SET BINARY" to a textual column and perform the character set encoding yourself.</p> <p>It is also worth reading <a href="http://dev.mysql.com/doc/refman/5.0/en/binary-varbinary.html" rel="nofollow">The BINARY and VARBINARY Types</a> from the MySQL manual as this details important information such as padding.</p> <p><strong>Summary:</strong> There is no technical difference as one is a synonym to the other. In my opinion it makes logical sense to store binary strings in data types that would normally hold a string using the "CHARACTER SET BINARY" and to store byte arrays / streams etc in BINARY fields that cannot be represented by transforming the data though a character set.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload