PostgreSQL MySQL 兼容性之 - 字符串类型

简介:
+关注继续查看

char

MySQL

  [NATIONAL] CHAR[(M)] [CHARACTER SET charset_name] [COLLATE collation_name]
  A fixed-length string that is always right-padded with spaces to the specified length when stored. M represents the column length in characters. The range of M is 0 to 255. If M is omitted, the length is 1.

PostgreSQL

[NATIONAL] CHAR[(M)] [COLLATE collation_name] 对应 PostgreSQL
  char[(M)] [COLLATE collation_name]

varchar

MySQL

  [NATIONAL] VARCHAR(M) [CHARACTER SET charset_name] [COLLATE collation_name]
  A variable-length string. M represents the maximum column length in characters. The range of M is 0 to 65,535.

PostgreSQL

[NATIONAL] VARCHAR(M) [COLLATE collation_name] 对应 PostgreSQL
  VARCHAR(M) [COLLATE collation_name]

BINARY CHAR BYTE

MySQL

  BINARY(M) , CHAR BYTE
  The BINARY type is similar to the CHAR type, but stores binary byte strings rather than non-binary character strings. M represents the column length in bytes.

PostgreSQL

  char([M])

VARBINARY(M)

MySQL

  VARBINARY(M)
  The VARBINARY type is similar to the VARCHAR type, but stores binary byte strings rather than non-binary character strings. M represents the maximum column length in bytes.
  It contains no character set, and comparison and sorting are based on the numeric value of the bytes.

PostgreSQL

  varchar[(M)]

BLOB

MySQL

  TINYBLOB  A BLOB column with a maximum length of 255 bytes. Each TINYBLOB value is stored using a one-byte length prefix that indicates the number of bytes in the value.
  MEDIUMBLOB  A BLOB column with a maximum length of 16,777,215 bytes. Each MEDIUMBLOB value is stored using a three-byte length prefix that indicates the number of bytes in the value.
  LONGBLOB A BLOB column with a maximum length of 4,294,967,295 bytes or 4GB. The effective maximum length of LONGBLOB columns depends on the configured maximum packet size in the client/server protocol and available memory. Each LONGBLOB value is stored using a four-byte length prefix that indicates the number of bytes in the value.
  BLOB[(M)]  A BLOB column with a maximum length of 65,535 bytes. Each BLOB value is stored using a two-byte length prefix that indicates the number of bytes in the value.

PostgreSQL

bytea , upto 1GB (support compression, pglz)
large object , upto 4TB (support compression)

TEXT

MySQL

  TINYTEXT [CHARACTER SET charset_name] [COLLATE collation_name]
    A TEXT column with a maximum length of 255 characters. The effective maximum length is less if the value contains multi-byte characters. Each TINYTEXT value is stored using a one-byte length prefix that indicates the number of bytes in the value.
  TEXT[(M)] [CHARACTER SET charset_name] [COLLATE collation_name]
    A TEXT column with a maximum length of 65,535 characters. The effective maximum length is less if the value contains multi-byte characters.
  MEDIUMTEXT [CHARACTER SET charset_name] [COLLATE collation_name]
    A TEXT column with a maximum length of 16,777,215 characters. The effective maximum length is less if the value contains multi-byte characters.
  LONGTEXT [CHARACTER SET charset_name] [COLLATE collation_name]
    A TEXT column with a maximum length of 4,294,967,295 or 4GB characters. The effective maximum length is less if the value contains multi-byte characters.

PostgreSQL

  不支持设置字段的CHARACTER SET, CHARACTER SET是库级别的属性.
  text
    upto 1G
  OR
  varchar[(M)]
    upto 1G

enum

MySQL

  ENUM('value1','value2',...) [CHARACTER SET charset_name] [COLLATE collation_name]
    An enumeration. A string object that can have only one value, chosen from the list of values 'value1', 'value2', ..., NULL or the special '' error value. 
    In theory, an ENUM column can have a maximum of 65,535 distinct values;
    in practice, the real maximum depends on many factors. ENUM values are represented internally as integers.

PostgreSQL

  不支持设置字段的CHARACTER SET, CHARACTER SET是库级别的属性.
  enum

SET

MySQL

  SET('value1','value2',...) [CHARACTER SET charset_name] [COLLATE collation_name]
    A set. A string object that can have zero or more values, each of which must be chosen from the list of values 'value1', 'value2', ... 
    A SET column can have a maximum of 64 members. 
    SET values are represented internally as integers.

PostgreSQL

  enum
相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
目录
相关文章
|
2天前
|
关系型数据库 MySQL 分布式数据库
直播预告 | MySQL & PostgreSQL 终极大比拼!
MySQL、PostgreSQL,乃至各种各样的数据库,孰强孰弱,难以辨别。究其原因,只因”不识庐山真面目,只缘身在此山中“。只需跳出”数据库“三字,一切自然看的分明。9月22日,解读如何换个维度,发现真相。
|
2天前
|
存储 关系型数据库 MySQL
PostgreSQL与MySQL优劣势比较浅谈
PostgreSQL与MySQL优劣势比较浅谈
6 0
|
5天前
|
Cloud Native OLAP 关系型数据库
云原生数据仓库AnalyticDB MySQL版/PostgreSQL版(二)
云原生数据仓库AnalyticDB MySQL版/PostgreSQL版(二)
29 0
|
5天前
|
人工智能 关系型数据库 Serverless
|
5天前
|
关系型数据库 数据库 PostgreSQL
云数据库RDS PostgreSQL 快速入门(二)
云数据库RDS PostgreSQL 快速入门(二)
22 1
|
5天前
|
关系型数据库 MySQL 数据库
MySQL 和 PostgreSQL,我到底选择哪个?
MySQL 和 PostgreSQL,我到底选择哪个?
20 0
|
10天前
|
监控 关系型数据库 数据库
RDS PostgreSQL内置连接池PgBouncer
2023年7月,阿里云RDS PostgreSQL支持内置数据库连接池PgBouncer,本篇文章从以下角度探讨PgBouncer:1. PgBouncer是什么;2. 应用场景 ;3. 性能对比;4. 如何使用;5. 总结
|
16天前
|
人工智能 关系型数据库 Serverless
探索AI知识库问答应用:函数计算与RDS PostgreSQL的奇妙融合
随着技术的飞速发展,AI大语言模型成为了当今科技界的一颗璀璨明星。我有幸跟随老陈的引导,踏入了基于函数计算(FC)和RDS PostgreSQL的AI知识库问答应用的世界。这次的探索让我深切感受到了云计算和人工智能的结合,以及它们如何塑造着未来的技术格局。
|
19天前
|
人工智能 关系型数据库 Serverless
阿里函数计算FC、文件存储NAS和RDS PostgreSQL的应用体验报告
本次体验的目的,旨在详细介绍如何通过阿里函数计算FC部署ChatGLM6B大语言模型,并借助文件存储NAS和RDS PostgreSQL搭建一个AI知识库问答应用,以实现PDF、TXT、HTML等文件和URL类型资料的轻松读取和处理。
75 50
|
19天前
|
关系型数据库 Serverless 数据库
RDS PostgreSQL Serverless部署心得分享
RDS PostgreSQL Serverless部署心得分享
相关产品
云数据库 Redis 版
云数据库 MongoDB 版
云数据库 RDS
推荐文章
更多