LoginSignup
0
0

More than 1 year has passed since last update.

Laravelのmigrationで使用するunsignedTinyInteger()とは何ぞやと調べてみた話

Last updated at Posted at 2022-12-22

追記

なし

はじめに

unsignedTinyInteger()とはなんやとなりましたので、調べました。
すごい簡単でしたが、まとめときます。

今回は、unsignedTinyIntegerですが、その他のunsigned~も同じような感じでした。(書くのがめんどくさいわけじゃないです、すいません)

調査

unsignedTinyInteger()とは

unsignedTinyIntegerメソッドはUNSIGNED TINYINTカラムを作成します。

$table->unsignedTinyInteger('sample');

UNSIGNED TINYINTカラムとは

MySQLのフィールド定義に「UNSIGNED」を定義すると、
今回の場合(TINYINT)なら、TINYINT型では通常扱える範囲はー128~127ですが、UNSIGNEDを定義することで0~255になります。
負数が使えなくなる代わりにその分扱える正の値が増えることになります。

まとめ

これからはUNSIGNEDが出てきても大丈夫そうです。

参考リンク

0
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
0
0