Help us understand the problem. What is going on with this article?

Laravelのカラム作成で使えるデータ型

More than 1 year has passed since last update.

Laravelでカラムを作る際に使えるデータ型がわからなかったので、よく使いそうなものを自分用にメモ

  • increments('id') ... 「符号なしINT」を使用した自動増分ID(主キー)
  • binary('カラム名') ... バイナリデータカラム
  • boolean('カラム名') ... 真偽値カラム
  • char('カラム名', 長さ) ... 長さを指定する文字列カラム
  • date('カラム名') ... 日付カラム
  • time('カラム名') ... 時間カラム
  • dateTime(カラム名) ... 日時カラム
  • double('カラム名', 桁数, 小数点以下桁数) ... ○桁で小数点以下×桁の小数カラム
  • enum('カラム名', ['定数', '定数']) ... ENUMカラム
  • integer('カラム名') ... 数値データカラム
  • json('カラム名') ... JSONフィールドカラム
  • timestamp('カラム名') ... TIMESTAMPカラム
  • timestamps() ... created_atとupdate_atカラム
  • nullableTimestamps() ... NULL値を許す以外、timestamps()と同じ
  • string('カラム名') ... VARCHARカラム
  • string('カラム名', 長さ) ... 長さ指定のVARCHARカラム
  • text('カラム名') ... TEXTカラム
Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away