PostgreSQL:real类型的比较

PostgreSQL的数据类型,对于小数来说,有decimal、numeric、real、double precision四种类型,在文档中,其定义为:

Name Storage Size Description Range
decimal variable user-specified precision, exact up to 131072 digits before the decimal point; up to 16383 digits after the decimal point
numeric variable user-specified precision, exact up to 131072 digits before the decimal point; up to 16383 digits after the decimal point
real 4 bytes variable-precision, inexact 6 decimal digits precision
double precision 8 bytes variable-precision, inexact 15 decimal digits precision

注意,real、double的描述为inexact,此时要用此类型进行逻辑判断的话,需要专门处理。

如下述的sql语句,其中lon、lat就定义为real类型:

select tid from taxi where lon1=lon2 and lat1=lat2

这个语句就不能正确的返回结果,需要这样处理才可以返回结果:

select tid from taxi where lon1::numeric=lon2::numeric and lat1::numeric=lat2::numeric

即需要将其转换成numeric类型进行精确判断。


已发布

分类

来自

标签:

评论

《 “PostgreSQL:real类型的比较” 》 有 12 条评论

  1. generique kamagra pharmacie envoyer annuaire

    comment obtenir une prescription kamagra

  2. purchase enclomiphene canadian pharmacy no prescription

    how to get it up without enclomiphene

  3. how to order androxal cheap online pharmacy

    buy cheap androxal uk how to get

  4. online order flexeril cyclobenzaprine generic uae

    flexeril cyclobenzaprine Canada order

  5. buy fildena spain over the counter

    cheap fildena canada fast shipping

  6. buy gabapentin generic united states

    gabapentin online discount

  7. how to order itraconazole generic online pharmacy

    how to buy itraconazole generic equivalent buy

  8. cheapest buy staxyn generic online mastercard

    get staxyn generic real

  9. cheap avodart generic in usa

    buying avodart purchase from canada

  10. purchase rifaximin uk how to get

    buy cheap rifaximin price prescription

  11. cheap xifaxan generic pharmacy online

    get xifaxan cost usa

  12. noト肱テュ dodテ。nテュ kamagra bez lテゥkaナ冱kテゥho pナ册dpisu

    kamagra lékové interakce

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注