答案:实际上"::"是调用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
上一个:让你的insert操作速度增加1000倍的方法
下一个:收缩数据库不变小的解决方法