
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
How MySQL reacts when we specify a CHARACTER SET binary attribute for a character string data type?
On specifying a CHARACTER SET binary attribute for a character string data type, MySQL creates that column as its subsequent binary string type. The conversions for CHAR, VARCHAR and BLOB data types take place as follows −
- CHAR would become BINARY
- VARCHAR would become VARBINARY
- TEXT would become BLOB
The above kind of conversion does not occur for ENUM and SET data type and they both are created as declared while creating the table.
Example
In the example below we have created a table named ‘EMP’ with four columns all specified as CHARACTER SET binary as follows −
mysql> Create table Emp(Name varchar(10) CHARACTER SET binary, Address CHAR(10)CHARACTER SET binary, Designation TEXT CHARACTER SET binary, Field ENUM('ENG','SS') CHARACTER SET binary); Query OK, 0 rows affected (0.16 sec)
But now on checking the status of table, with the help of query below, we can see that MySQL has changed the data type according to its subsequent binary string.
mysql> Show Create Table EMP\G *************************** 1. row *************************** Table: EMP Create Table: CREATE TABLE `emp` ( `Name` varbinary(10) DEFAULT NULL, `Address` binary(10) DEFAULT NULL, `Designation` blob, `Field` enum('ENG','SS') CHARACTER SET binary DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 1 row in set (0.00 sec)
- Related Articles
- How can we produce a string, other than default binary string, in a given character set by MySQL CHAR() function?
- How can we check the character set of all the tables in a particular MySQL database?
- Set the default character set in MySQL
- How to search for ^ character in a MySQL table?
- What MySQL functions can we use to change the character case of a string?
- How do we split a string on a fixed character sequence in java?
- Generating a unique random 10 character string using MySQL?
- Get part of a string based on a character in MySQL?
- Getting last 5 character of a string with MySQL query?
- Python program for removing nth character from a string
- How do I see what character set a MySQL database / table / column is?
- How to check if a string contains only one type of character in R?
- C program for testing the character type
- How can we check the default character sets of a particular MySQL database?
- In MySQL, how can we get the number code of a particular character?

Advertisements