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?

Go PostgreSQLの数値型チートシート

Posted at

概要

GoとPostgreSQLで開発を行っている際に、双方の数値型に混乱することが多々あり、せっかくなのでまとめたものを公開します。

型の対比

PostgreSQLの
数値型
Goの
数値型
説明 範囲
smallint int16 16-bit、2バイト -32768~32767
integer int32 32-bit、4バイト -2147483648
~2147483647
bigint int64 64-bit、8バイト -9223372036854775808
~9223372036854775807
decimal string 可変長
ユーザ指定精度
正確
小数点前: 131072桁
小数点以降:16383桁
numeric string 可変長
ユーザ指定精度
正確
小数点前: 131072桁
小数点以降:16383桁
real float64 64-bit、不正確 6桁精度
double precision float64 64-bit、不正確 15桁精度
smallserial int16 16-bit、2バイト 1~32767
serial int32 32-bit、4バイト 1~2147483647
bigserial int64 64-bit、8バイト 1~9223372036854775807

参考文献

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?