PostgreSQL学习篇9.3 浮点数类型

[html]  view plain  copy
  1. 浮点数类型有:real、double precision,它们是不精确的、变精度的数字类型。  
  2.   
  3. 注意:  
  4. 1.要求精确计算的,需要使用numeric  
  5. 2.浮点数等值比较,可能不是想象中的结果。  
  6.   
  7. 浮点类型的特殊值:  
  8.   
  9.     * infinity  (正无穷)  
  10.     * -infinity  (负无穷)  
  11.     * NaN       (不是一个数字not a  number  
  12.   
  13. 示例:  
  14. postgres=# insert into test(col1) values ('InFiNity');  
  15. ERROR:  invalid input syntax for type numeric: "InFiNity"  
  16. LINE 1: insert into test(col1) values ('InFiNity');      ----numeric没有infinity  
  17.   
  18. postgres=# create table testflo(col1 real,col2 double precision);  
  19. CREATE TABLE  
  20. postgres=# \d testflo  
  21.         Table "public.testflo"  
  22.  Column |       Type       | Modifiers  
  23. --------+------------------+-----------  
  24.  col1   | real             |  
  25.  col2   | double precision |  
  26.   
  27. postgres=# insert into testflo values('InfInitY','-InfiniTY');  
  28. INSERT 0 1  
  29. postgres=# insert into testflo values('InfiNity','nan');  
  30. INSERT 0 1  
  31. postgres=# select * from testflo;  
  32.    col1   |   col2     
  33. ----------+-----------  
  34.  Infinity | -Infinity  
  35.  Infinity |       NaN  
  36. (2 rows)  
  37.   
  38. postgres=#  
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值