To convert a string expression to a binary string, these constructs are equivalent: 

CAST( expr  AS BINARY) CONVERT( expr  USING BINARY) BINARY expr 

If a value is a string literal, it can be designated as a binary string without converting it by using the _binary  character set introducer: 

mysql> SELECT ’a’ = ’A’; -> 1 mysql> SELECT _binary ’a’ = ’A’; -> 0 

For information about introducers, see Section 10.3.8, “Character Set Introducers” . 

The BINARY  operator in expressions differs in effect from the BINARY  attribute in character column definitions. For a character column defined with the BINARY  attribute, MySQL assigns the table default character set and the binary ( _bin ) collation of that character set. Every nonbinary character set has a _bin  collation. For example, if the table default character set is utf8mb4 , these two column definitions are equivalent: 

CHAR(10) BINARY CHAR(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin 

The use of CHARACTER SET binary  in the definition of a CHAR , VARCHAR , or TEXT  column causes the column to be treated as the corresponding binary string data type. For example, the following pairs of definitions are equivalent: 

CHAR(10) CHARACTER SET binary BINARY(10) VARCHAR(10) CHARACTER SET binary VARBINARY(10) TEXT CHARACTER SET binary BLOB 

If BINARY  is invoked from within the mysql  client, binary strings display using hexadecimal notation, depending on the value of the --binary-as-hex . For more information about that option, see Section 4.5.1, “mysql — The MySQL Command-Line Client” . 

• CAST( expr  AS type  [ARRAY]) 

CAST( timestamp_value  AT TIME ZONE timezone_specifier  AS DATETIME[( precision )]) 

timezone_specifier : [INTERVAL] ’+00:00’ | ’UTC’ 

The CAST()  function takes an expression of any type and produces a result value of the specified type, similar to CONVERT() . For more information, see the description of CONVERT() . 

In MySQL 8.0.17 and higher, InnoDB  allows the use of an additional ARRAY  keyword for creating a multi-valued index on a JSON  array as part of CREATE INDEX , CREATE TABLE , and ALTER TABLE statements. ARRAY  is not supported except when used to create a multi-valued index in one of these statements, in which case it is required. The column being indexed must be a column of type JSON . With ARRAY , the type  following the AS  keyword may specify any of the types supported by CAST() , with the exceptions of BINARY , JSON , and YEAR . For syntax information and examples, as well as other relevant information, see Multi-Valued Indexes. 

