postgres8.3以后,字段数据之间的默认转换取消了。如果需要进行数据变换的话,在postgres数据库中,我们可以用"::"来进行字段数据的类型转换。实际上"::"是调用CAST函数的。究竟哪些字段之间可以进行数据转换呢?

   这个问题只要研究一下cast函数就能够得到答案。cast函数的信息在系统pg_cast表里面管理。

通过查询我们可以得到现阶段可以转换的类型对照表如下:

源类型            转换目标类型

int8 int2
int8 int4
int8 float4
int8 float8
int8 numeric
int2 int8
int2 int4
int2 float4
int2 float8
int2 numeric
int4 int8
int4 int2
int4 float4
int4 float8
int4 numeric
float4 int8
float4 int2
float4 int4
float4 float8
float4 numeric
float8 int8
float8 int2
float8 int4
float8 float4
float8 numeric
numeric int8
numeric int2
numeric int4
numeric float4
numeric float8
int4 bool
bool int4
int8 oid
int2 oid
oid int8
int8 regproc
int2 regproc
regproc int8
int8 regprocedure
int2 regprocedure
regprocedure int8
int8 regoper
int2 regoper
regoper int8
int8 regoperator
int2 regoperator
regoperator int8
int8 regclass
int2 regclass
regclass int8
int8 regtype
int2 regtype
regtype int8
int8 regconfig
int2 regconfig
regconfig int8
int8 regdictionary
int2 regdictionary
regdictionary int8
text regclass
varchar regclass
bpchar text
bpchar varchar
char text
char bpchar
char varchar
name text
name bpchar
name varchar
text char
bpchar char
varchar char
text name
bpchar name
varchar name
char int4
int4 char
abstime date
abstime time
abstime timestamp
abstime timestamptz
reltime interval
date timestamp
date timestamptz
time interval
time timetz
timestamp abstime
timestamp date
timestamp time
timestamp timestamptz
timestamptz abstime
timestamptz date
timestamptz time
timestamptz timestamp
timestamptz timetz
interval reltime
interval time
timetz time
lseg point
path point
path polygon
box point
box lseg
box polygon
box circle
polygon point
polygon path
polygon box
polygon circle
circle point
circle box
circle polygon
inet cidr
int8 bit
int4 bit
bit int8
bit int4
cidr text
inet text
bool text
text xml
cidr varchar
inet varchar
bool varchar
varchar xml
cidr bpchar
inet bpchar
bool bpchar
bpchar xml
bpchar bpchar
varchar varchar
time time
timestamp timestamp
timestamptz timestamptz
interval interval
timetz timetz
bit bit
varbit varbit
numeric numeric

postgres数据库中的数据转换的更多相关文章

  1. DELPHI 把数据库中的数据转换成XML格式

    function ReplaceString(AString: string): string; begin Result := StringReplace(AString, '&', '&a ...

  2. 在ef core中使用postgres数据库的全文检索功能实战

    起源 之前做的很多项目都使用solr/elasticsearch作为全文检索引擎,它们功能全面而强大,但是对于较小的项目而言,构建和维护成本显然过高,尤其是从关系数据库/文档数据库到全文检索引擎的数据 ...

  3. 在ef core中使用postgres数据库的全文检索功能实战之中文支持

    前言 有关通用的postgres数据库全文检索在ef core中的使用方法,参见我的上一篇文章. 本文实践了zhparser中文插件进行全文检索. 准备工作 安装插件,最方便的方法是直接使用安装好插件 ...

  4. Postgres数据库在Linux中优化

    I/O 优化1 打开 noatime nodirtime,async 方法: 修改 /etc/fstab stat 命令查看 2 调整预读方法: 查看 sudo blockdev --getra /d ...

  5. 使用Sqoop,最终导入到hive中的数据和原数据库中数据不一致解决办法

            Sqoop是一款开源的工具,主要用于在Hadoop(Hive)与传统的数据库(mysql.postgresql...)间进行数据的传递,可以将一个关系型数据库(例如 : MySQL , ...

  6. Postgres数据库基本介绍

    最近一直在做一个和PostgreSQL数据库相关的项目,把自己在这个过程中学习的知识记录下来.关于PostgreSQL数据库网上已经有太多的相关介绍了,为了博文的系统性还是先看一下维基百科对Postg ...

  7. pgadmin(IDE)工具连接postgres数据库

    1. 下载软件        软件地址:http://www.pgadmin.org/download/pgagent.php   2.安装软件    安装过程:略    打开软件64位会出现  “无 ...

  8. Metasploit连接postgres数据库

    操作环境为Kali虚拟机 root@kali:~# apt-get install postgresql 启动服务 root@kali:~# service postgresql start [ ok ...

  9. ubuntu crontab 定时备份postgres数据库并上传ftp服务器

    最近公司要求备份数据库,所以就查了比较作的资料.废话不多说,入正题. 目的:定期备份ubuntu下的postgres数据库,打包上传到指定ftp服务器. 经过查找资料,解决方法: ①编写备份数据库.打 ...

随机推荐

  1. C++11空指针

    [C++11空指针] 早在 1972 年,C语言诞生的初期,常数 0 带有常数及空指针的双重身分. C 使用 preprocessor macro NULL 表示空指针, 让 NULL 及 0 分别代 ...

  2. This is a sandbox of markdown

    A First Level Header A Second Level Header Now is the time for all good men to come to the aid of th ...

  3. js 控制DIV 预览打印

    Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--> ...

  4. 导入导出Excel

    最近需要频繁的使用导入导出,各么,又不想使用ms的PIA,在4.0以下,存在版本兼容的问题. 于是网上查找了很久,找到两款开源的excel组件. 1.CSharpJExcel,这是JExcel的.ne ...

  5. 大数据平台搭建(hadoop+spark)

    大数据平台搭建(hadoop+spark) 一.基本信息 1. 服务器基本信息 主机名 ip地址 安装服务 spark-master 172.16.200.81 jdk.hadoop.spark.sc ...

  6. linq 动态排序,不使用反射

    之前网上搜索的相关方法都是使用了反射的方法来动态获取字段,以实现动态linq排序,但是因为项目组觉得此方法效率低下,所以不予采纳. 所以有了以下代码 public interface IBase{ d ...

  7. SRM 451 DIV 1 总结

    250p:这次是有史以来做的最快的一次250p...看题花了两分钟,敲代码最多一分钟...太明显了题意~ 500p:这题水了...每次都这样...很显然用DP来做,不过前面状态表示有问题了...搞了好 ...

  8. A debugger is already attached

    Today is the last day that all the laptops of winXP OS should be upgrade to WIN7. After updated. whe ...

  9. 729 - The Hamming Distance Problem

      // 题意: // 输入两个整数N, H,按照字典序输出所有长度为N,恰好包含H个1的01串 // 规模:1<=H<=N<=16 // 算法A:2^N枚举,输出1的个数为H的.采 ...

  10. 如何查询redhat的版本信息

    cat /etc/redhat-release lsb_release -a