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服务器. 经过查找资料,解决方法: ①编写备份数据库.打 ...
随机推荐
- windows平台下,快速删除所有.svn文件夹
新建一个注册表文件名为:DELSVN.reg编辑其内容如下: Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\Cla ...
- How to run a terminal inside of vim?
[How to run a terminal inside of vim?] :sh turn vim into shell mode d+trl back to vim 参考:http://stac ...
- 使用python获得git中分支存成list
通过这个搜集git工程下的branch信息例子,来说明一下python和终端的信息交互,和字符串的简单处理.代码如下: ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 ...
- 函数 MultiByteToWideChar() 详解
函数原型: int MultiByteToWideChar( UINT CodePage, DWORD dwFlags, LPCSTR lpMultiByteStr, int cchMultiByte ...
- Regular Expression--Good parts
匹配URL的正则表达式 <!doctype html><html lang="en"><head> <meta charset=" ...
- 1.单一职责原则(Single Responsibility Principle)
1.定义 就一个类而言,应该仅有一个引起它变化的原因. 2.定义解读 这是六大原则中最简单的一种,通俗点说,就是不存在多个原因使得一个类发生变化,也就是一个类只负责一种职责的工作. 3.优点 类的复杂 ...
- FlashPaper 使用经验之谈
李志海 20101229 QQ:76855049 CSDN:资源下载地址:http://lizhihai_99.download.csdn.net/ http://download.csdn.ne ...
- How a non-windowed component can receive messages from Windows -- AllocateHWnd
http://www.delphidabbler.com/articles?article=1 Why do it? Sometimes we need a non-windowed componen ...
- IE兼容CSS3圆角border-radius的方法(同时兼容box-shadow,text-shadow)
IE兼容CSS3圆角border-radius,box-shadow,text-shadow的方法 1.下载ie-css3.htc 2.CSS box { -moz-border-radius: 15 ...
- Study notes for Clustering and K-means
1. Clustering Analysis Clustering is the process of grouping a set of (unlabeled) data objects into ...