iis服务器助手广告广告
返回顶部
首页 > 资讯 > 数据库 >当我们为字符串数据类型指定 CHARACTER SET 二进制属性时,MySQL 如何反应?
  • 319
分享到

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

2023-10-22 10:10:55 319人浏览 安东尼
摘要

On specifying a CHARACTER SET binary attribute for a character string data type, Mysql creates that column as its subseq

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)
您可能感兴趣的文档:

--结束END--

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

本文链接: https://www.lsjlt.com/news/437364.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作