Schema Builder length of an integer

前端 未结 6 913
一整个雨季
一整个雨季 2021-01-01 21:17

I\'ve been searching around and the question was asked a few times, but no-one seem to be able to give a definite answer to it. How do you specify the integer length for the

6条回答
  •  囚心锁ツ
    2021-01-01 21:41

    Thought I'd create an easy-to-copy-and-paste for general situations table.
    Signed if you do require negative values and unsigned if you do not.

    | Type                | Eloquent (Schema Builder)                 | Min     | Max    |
    | ------------------- | ----------------------------------------- | ------- | ------ |
    | TINYINT (Signed)    | $table->signedTinyInteger('foo')          | -128    | 127    |
    | TINYINT (Unsigned)  | $table->unsignedTinyInteger('foo')        | 0       | 255    |
    | SMALLINT (Signed)   | $table->signedSmallInteger('foo')         | -32768  | 32767  |
    | SMALLINT (Unsigned) | $table->unsignedSmallInteger('foo')       | 0       | 65535  |
    

    For larger Integer types, see: https://dev.mysql.com/doc/refman/5.5/en/integer-types.html

提交回复
热议问题