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++面试题总结(2)

    1. C中static有什么作用 (1)隐藏. 当我们同时编译多个文件时,所有未加static前缀的全局变量和函数都具有全局可见性,故使用static在不同的文件中定义同名函数和同名变量,而不必担心命 ...

  2. $watch How the $apply Runs a $digest

    作者:junyuecao | 发表于 8-8 13:39 | 最后更新时间:8-9 02:34 原文地址:http://angular-tips.com/blog/2013/08/watch-how- ...

  3. devexpress皮肤设置

    DEV的皮肤管理控件:SkinController: TdxSkinController; 皮肤设置:SkinController.SkinName := appInfo.SkinName; TdxR ...

  4. 用PyInstaller把Python代码打包成单个独立的exe可执行文件

    之前就想要把自己的BlogsToWordpress打开成exe了.一直没去弄. 又看到有人提到python打开成exe的问题. 所以打算现在就去试试. 注:此处之所有选用BlogsToWordpres ...

  5. all & any

    def all(*args, **kwargs): """ Return True if bool(x) is True for all values x in the ...

  6. C# JackLib系列之如何获取地球上两经纬度坐标点间的距离

    获取地球上两经纬度坐标点间的距离,利用[大圆距离公式]   A diagram illustrating great-circle distance (drawn in red) between tw ...

  7. cf754 B. Ilya and tic-tac-toe game

    呵呵呵,这个题简直是一直在乱做,真是最近太弱了 #include<bits/stdc++.h> #define lowbit(x) x&(-x) #define LL long l ...

  8. C++开发必看 四种强制类型转换的总结 [转]

    一.C风格的强制类型转换(Type Cast)很简单,不管什么类型的转换统统是:     TYPE b = (TYPE)a 二.C++风格的类型转换提供了4种类型转换操作符来应对不同场合的应用. co ...

  9. Linux 中使用 KVM

    from:http://www.php-oa.com/2010/02/22/ubutnu-kvm-vmware.html 听讲XEN很快就要从LINUX内核中去掉,redhat和Ubuntu也大力的在 ...

  10. js 创建List<Map> 这种格式的集合

    //赋值 var list_map = new Array(); for ( var i = 0; i < 10; i++) { list_map.push({baidux:'baidux'+i ...