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. TransactionScope事务对多个数据库的操作

    .Net 2.0引入了轻量级事务管理器(Lighweight Transaction Manager),即System.Transactions.TransactionManager. 轻量级事务管理 ...

  2. MYSQL数据库性能调优之五:解决慢查询--存储引擎与数据类型

    3.数据类型的影响 4.存储引擎的影响 看你的mysql现在已提供什么存储引擎:mysql> show engines; 看你的mysql当前默认的存储引擎:mysql> show var ...

  3. vim之vba文件

    [vim之vba文件] Vimball 官方描述: The vimball plugin facilitates creating, extracting , and listing the cont ...

  4. POJ1338Ugly Numbers(DP)

    http://poj.org/problem?id=1338 第一反应就是DP,DP[i] = min{2*DP[j], 3*DP[k], 5*DP[p] j,k,p<i};于是枚举一下0-i- ...

  5. poj1584

    题意:已知一个多边形的n个顶点坐标,然后再给一个钉子,给定钉子的半径和圆心坐标,首先判断多边形是否为凸多边形,若为凸多边形,再判断钉子是否可以放到凸多边形内部. 思路: 1.由于顶点给出的顺序可能为逆 ...

  6. MVC6与Asp.net5

    http://www.cnblogs.com/n-pei/p/4263148.html https://blogs.msdn.microsoft.com/scottgu/2015/04/30/asp- ...

  7. visual studio 设计器上出现蓝色的点和箭头

    visual studio 设计器上出现蓝色的点和箭头: 突然发现打开visual studio 的时候出现了很多蓝色的点和箭头,解决办法是:按组合快捷键 Ctrl+R,Ctrl+W 或 Ctrl+E ...

  8. jquery 选择器中含有空格注意

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  9. .NET开发中的事务处理大比拼

    本文转载:http://www.cnblogs.com/jhxk/articles/2696307.html http://liubaolongg.blog.163.com/blog/static/2 ...

  10. 分布式文件系统FastDFS设计原理

    原文地址: http://blog.chinaunix.net/uid-20196318-id-4058561.html FastDFS是一个开源的轻量级分布式文件系统,由跟踪服务器(tracker ...