title rails migration中integer column的limit
description rails migration中integer column的limit
datetime 2014-11-13 10:05:47
tags rails_migration
category coding
link rails-migration-integer-column-limit
file 2014-11-13-100547-rails-migration-integer-column-limit
template post
end
integer的limit其實指的是byte的長度,而不是字串的長度,下面是對應表:
:limit | SQL的資料型態 | 大小 | 最大值 |
1 | tinyint | 1 byte | 127 |
2 | smallint | 2 byte | 32767 |
3 | mediumint | 3 byte | 8388607 |
nil, 4, 11 | int(11) | 4 byte | 2147483647 |
5..8 | bigint | 8 byte | 9223372036854775807 |
Once and for all: Rails migrations integer :limit option