postgres数据库中的数据转换
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数据库中的数据转换的更多相关文章
- DELPHI 把数据库中的数据转换成XML格式
function ReplaceString(AString: string): string; begin Result := StringReplace(AString, '&', '&a ...
- 在ef core中使用postgres数据库的全文检索功能实战
起源 之前做的很多项目都使用solr/elasticsearch作为全文检索引擎,它们功能全面而强大,但是对于较小的项目而言,构建和维护成本显然过高,尤其是从关系数据库/文档数据库到全文检索引擎的数据 ...
- 在ef core中使用postgres数据库的全文检索功能实战之中文支持
前言 有关通用的postgres数据库全文检索在ef core中的使用方法,参见我的上一篇文章. 本文实践了zhparser中文插件进行全文检索. 准备工作 安装插件,最方便的方法是直接使用安装好插件 ...
- Postgres数据库在Linux中优化
I/O 优化1 打开 noatime nodirtime,async 方法: 修改 /etc/fstab stat 命令查看 2 调整预读方法: 查看 sudo blockdev --getra /d ...
- 使用Sqoop,最终导入到hive中的数据和原数据库中数据不一致解决办法
Sqoop是一款开源的工具,主要用于在Hadoop(Hive)与传统的数据库(mysql.postgresql...)间进行数据的传递,可以将一个关系型数据库(例如 : MySQL , ...
- Postgres数据库基本介绍
最近一直在做一个和PostgreSQL数据库相关的项目,把自己在这个过程中学习的知识记录下来.关于PostgreSQL数据库网上已经有太多的相关介绍了,为了博文的系统性还是先看一下维基百科对Postg ...
- pgadmin(IDE)工具连接postgres数据库
1. 下载软件 软件地址:http://www.pgadmin.org/download/pgagent.php 2.安装软件 安装过程:略 打开软件64位会出现 “无 ...
- Metasploit连接postgres数据库
操作环境为Kali虚拟机 root@kali:~# apt-get install postgresql 启动服务 root@kali:~# service postgresql start [ ok ...
- ubuntu crontab 定时备份postgres数据库并上传ftp服务器
最近公司要求备份数据库,所以就查了比较作的资料.废话不多说,入正题. 目的:定期备份ubuntu下的postgres数据库,打包上传到指定ftp服务器. 经过查找资料,解决方法: ①编写备份数据库.打 ...
随机推荐
- 深入浅出谈存储之NAS是什么
深入浅出谈存储之NAS是什么 2012年02月17日16:42 来源:新浪博客 作者:林沛满 编辑:曾智强 查看全文 赞(0)评论(0) 分享 标签: NAS , 企业NAS , 存储系统 [IT16 ...
- [转]比较 Rational Unified Process (RUP) 和 Microsoft Solutions Framework (MSF)
文档选项 将此页作为电子邮件发送 级别: 初级 Sandra Sergi Santos, 软件工程专家, IBM 2007 年 6 月 15 日 本文来自于 Rational Edge:Micro ...
- 山东意外险风险信息推送V7非车
<?xml version="1.0" encoding="GBK"?><Packet type="REQUEST" ve ...
- ESB 客户端调用 处理类
esb package com.isoftstone.synchronize.entrance; import java.io.File; import java.text.SimpleDateFor ...
- 解决ehcache的UpdateChecker问题
问题描述 项目中用了ssh框架,每次启动tomcat的时候都特别慢,会在这样一句话下面停留很久 [2016-01-08 23:55:51,517 INFO UpdateChecker.java:doC ...
- poj 3216 Repairing Company(最短路Floyd + 最小路径覆盖 + 构图)
http://poj.org/problem?id=3216 Repairing Company Time Limit: 1000MS Memory Limit: 131072K Total Su ...
- Windows 7 不同安装模式简要区别(图解)
★ 你可能对GHOST不支持AHCI感到迷惑,实际上,写过GHOST一键安装批处理的都知道一个叫FINDCD.EXE的小程序,可是这个程序老 了,AHCI模式光驱他找不到了,找不到光驱动意味着光盘中G ...
- JQuery 的bind和unbind函数
测试:页面代码:<body> <input type="button" name="aaa" value="点击我" ...
- 完整Deploy WebPlayer的Config
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xht ...
- DateTable与List<T>相互转换 及JSON与DataTable(DataSet)相互转化
http://www.360doc.com/content/13/0712/09/10504424_299336674.shtml Linq处理List数据 http://blog.163.com/l ...