登录
首页 >  数据库 >  MySQL

当我们为字符串数据类型指定 CHARACTER SET 二进制属性时,MySQL 如何反应?

来源:tutorialspoint

时间:2023-08-26 18:57:56 356浏览 收藏

golang学习网今天将给大家带来《当我们为字符串数据类型指定 CHARACTER SET 二进制属性时,MySQL 如何反应?》,感兴趣的朋友请继续看下去吧!以下内容将会涉及到等等知识点,如果你是正在学习数据库或者已经是大佬级别了,都非常欢迎也希望大家都能给我建议评论哈~希望能帮助到大家!

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)

今天关于《当我们为字符串数据类型指定 CHARACTER SET 二进制属性时,MySQL 如何反应?》的内容就介绍到这里了,是不是学起来一目了然!想要了解更多关于的内容请关注golang学习网公众号!

声明:本文转载于:tutorialspoint 如有侵犯,请联系study_golang@163.com删除
相关阅读
更多>
最新阅读
更多>
课程推荐
更多>