1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

浮動小数点データ型で、realとdouble precisionのどっちを使うべきか

Posted at

はじめに

テーブル設計をする時、浮動小数点を扱うデータ型に、realと、double precisionと2種類あるが、どっちを選ぶべきかについてまとめてみた。

環境

PostgreSQL 9.5

説明

オフィシャルドキュメントを見ると、real6桁精度double precision15桁精度とある。

https://www.postgresql.jp/document/9.3/html/datatype-numeric.html
image.png

6桁精度とは、整数部+小数部で6桁以下という事で、15桁精度とは、整数部+小数部で15桁以下という事。(この時、小数点は含めません)

見た方が早いと思うので、データを格納してみる。つまり、このようなデータが格納できるという事です。
image.png

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?