类型名称 | 存储空间 | 描述 |
smallint | 2字节 | 小范围整数。Oracle中没有此类型,使用number代替 |
int或integer | 4字节 | 常用的整数。Oracle中的integer等效于number(38),与此类型的意义不同 |
bigint | 8字节 | 大范围的整数。Oracle中没有此类型,使用number代替。 |
numeric或decimal | 变长 | 用户声明的精度,精确。注意Oracle中叫number,与PG中名称不一致。 |
real | 4字节 | 变精度,不精确。 |
double precision | 8字节 | 变精度,不精确。 |
serial | 4字节 | 自增整数。 |
bigserial | 8字节 | 大范围的自增整数。 |
整数类型整数类型有三种:smallint、int、bigintint、integer、int4等效;int2、smallint等效;bigint、int8等效。精确的小数类型精确的小树类型可用numeric、numeric(m,n)、numeric(m)表示。numeric与decimal等效,可以存储最多1000位精度的数字,并且可以进行准确的计算。适合货币金额和其他要求精确计算的场合。不过,numeric类型上的算术运算比证书类型或浮点数类型慢很多(类似于Oracle里面的number,但是,Oracle中int相当于number(m,0))。示例:postgres=# create table test(col1 numeric(3),col2 numeric(3,0),col3 numeric(3,2),col4 numeric);CREATE tablepostgres=#postgres=# insert into test values (2,2,2.222,2.222);INSERT 0 1postgres=# select * from test; col1 | col2 | col3 | col4 ------+------+------+------- 2 | 2 | 2.22 | 2.222(1 row)postgres=# insert into test values(22,22,22.222,22.222);ERROR: numeric fIEld overflowDETAIL: A fIEld with precision 3,scale 2 must round to an absolute value less than 10^1.总结
以上是内存溢出为你收集整理的PostgreSQL学习篇9.2 数值类型全部内容,希望文章能够帮你解决PostgreSQL学习篇9.2 数值类型所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)