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
时间: 2024-11-01 23:58:38

PostgreSQL MySQL 兼容性之 - 字符串类型的相关文章

PostgreSQL MySQL 兼容性之 - Gis类型

PostGIS的GIS功能相比MySQL强大太多,本文仅仅列举了MySQL支持的部分.欲了解PostGIS请参考:http://postgis.net/docs/manual-2.2/reference.htmlPostGIS有几百个操作函数, 对GIS支持强大. POINT MySQL POINT PointFromText('POINT(10 10)') PointFromWKB(AsWKB(PointFromText('POINT(10 20)')) PostgreSQL # Postgr

PostgreSQL MySQL 兼容性之 - 数字类型

TINYINT MySQL TINYINT[(M)] [UNSIGNED] [ZEROFILL] A very small integer. The signed range is -128 to 127. The unsigned range is 0 to 255. PostgreSQL TINYINT 对应 PostgreSQL postgres=# create domain tinyint as smallint constraint ck check (value between -

PostgreSQL MySQL 兼容性之 - 时间类型

DATE MySQL DATE A date. The supported range is '1000-01-01' to '9999-12-31'. '0000-00-00' is a permitted special value (zero-date), unless the NO_ZERO_DATE SQL_MODE is used. Also, individual components of a date can be set to 0 (for example: '2015-00

PostgreSQL MySQL 兼容性之 - 空(NULL)

NULL compare operator <=> MySQL SELECT 99 <=> NULL, NULL <=> NULL; +-------------+---------------+ | 99 <=> NULL | NULL <=> NULL | +-------------+---------------+ | 0 | 1 | +-------------+---------------+ IS NULL IS NOT NULL

PostgreSQL MySQL 兼容性之 - bit 函数和操作符

bit 函数和操作符 MySQL & Bitwise AND << Left shift >> Shift right BIT_COUNT Returns the number of set bits ^ Bitwise XOR | Bitwise OR ~ Bitwise NOT PostgreSQL Operator Description Example Result || concatenation B'10001' || B'011' 10001011 &

PostgreSQL MySQL 兼容性之 - 读写用户的只读影子用户

在一些企业里面,通常会在数据库中创建一些只读用户,这些只读用户可以查看某些用户的对象,但是不能修改或删除这些对象的数据. 这种用户通常可以给开发人员,运营人员使用,或者数据分析师 等角色的用户使用. 因为他们可能关注的是数据本身,并且为了防止他们误操作修改或删除线上的数据,所以限制他们的用户只有只读的权限. MySQL这块的管理应该非常方便. 其实PostgreSQL管理起来也很方便. 用户可以先参考我前面写的两篇文章 PostgreSQL 逻辑结构 和 权限体系 介绍 https://yq.a

PostgreSQL MySQL 兼容性之 - 自增值

AUTO_INCREMENT , sequence MySQL AUTO_INCREMENT The AUTO_INCREMENT attribute can be used to generate a unique identity for new rows. When you insert a new record to the table, and the auto_increment field is NULL or DEFAULT, the value will automatical

Mysql如何在字符串类型的日期上加上10分钟并和现在的日期做比较

SELECT id FROM tran WHERE state = 'F' AND TIMESTAMPDIFF(SECOND,DATE_ADD(create_date,INTERVAL 10 DAY_MINUTE),"2014-06-18 10:30:29")>0 如果create_date加10分钟大于等于当前的时间("2014-06-18 10:30:29") 那么就会查到数据, 如果小于那么就查不到数据 本栏目更多精彩内容:http://www.bian

mysql-请教数据库大神,MySQL中的point类型数据取出来之后如何转化为字符串在后台使用?

问题描述 请教数据库大神,MySQL中的point类型数据取出来之后如何转化为字符串在后台使用? 请教数据库大神,MySQL中的point类型数据取出来之后如何转化为字符串在后台使用?我想通过这个得到的坐标去计算两个坐标之间的距离,但是取出来后没法转化成字符串,大神们,帮帮忙,谢谢了! 解决方案 select AsText(point) from T;