Numeric 數字

Numeric 數字

數字類型

類型 儲存空間 說明 資料範圍
smallint 2 bytes small integer -32768 to +32767
integer 4 bytes 一般整數 -2147483648 to +2147483647
bigint 8 bytes large integer -9223372036854775808 to +9223372036854775807
decimal 變動 使用者指定精度跟位數 up to 131072 digits before the decimal point; up to 16383 digits after the decimal point
numeric 變動 使用者指定精度跟位數 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
smallserial 2 bytes 自動增加 small integer 1 to 32767
serial 4 bytes 自動增加 integer 1 to 2147483647
bigserial 8 bytes 自動增加 large integer 1 to 9223372036854775807

NUMERIC(precision, scale)

欄位 說明 描述
Precision 精度 總數字數量
Scale 維度 小數點數字數量

範例

定義 數字範圍
numeric(5, 0) 11111
numeric(5, 1) 1111.1
numeric(5, 2) 111.11
numeric(5, 3) 11.111
numeric(5, 4) 1.1111

參考資料