t.decimal :hoge
と指定した場合の最大値と最小値はいくらでしょうか?
Out of range value for column
と出てしまうので、バリデーションをかけたいです。(わざわざ最大値と最小値にあわせることなくアプリ固有で恣意的に決めてしまってもよいとは思いますが...)
スタック・オーバーフローはプログラマーとプログラミングに熱心な人のためのQ&Aサイトです。すぐ登録できます。
登録してこのコミュニティに参加するdecimalの場合の最大値、最小値はデータベースによります。
Please be aware of different RDBMS implementations behavior with :decimal columns:
The SQL standard says the default scale should be 0, :scale <= :precision, and makes no comments about the requirements of :precision.
- MySQL: :precision [1..63], :scale [0..30]. Default is (10,0).
- PostgreSQL: :precision [1..infinity], :scale [0..infinity]. No default.
- SQLite2: Any :precision and :scale may be used. Internal storage as strings. No default.
- SQLite3: No restrictions on :precision and :scale, but the maximum supported :precision is 16. No default.
- Oracle: :precision [1..38], :scale [-84..127]. Default is (38,0).
- DB2: :precision [1..63], :scale [0..62]. Default unknown.
- SqlServer?: :precision [1..38], :scale [0..38]. Default (38,0).