Laravel8のmigrationで生成する各型の対応表

laravel

laravelのmigrationを使用していろいろなカラムタイプを定義するとmysql上ではどういう型になるかについて。

本家はこれ

カラム名は予約語と重なるものが多かったので、c_をカラムにつけて確認。

前半に型一覧、後半に実際の検証結果を掲載。

  1. 型の対応
    1. $table->bigIncrements(‘id’);
    2. $table->bigInteger(‘c_bigint’);
    3. $table->binary(‘c_binary’);
    4. $table->boolean(‘c_boolean’);
    5. $table->char(‘c_char’, 100);
    6. $table->date(‘c_date’);
    7. $table->dateTimeTz(‘c_datetimetz’, $precision = 0);
    8. $table->decimal(‘c_decimal’, $precision = 8, $scale = 2);
    9. $table->double(‘c_double’, 8, 2);
    10. $table->enum(‘c_enum’, [‘easy’, ‘normal’, ‘hard’]);
    11. $table->float(‘c_float’, 8, 2);
    12. $table->foreignId(‘c_foreignid’);
    13. $table->geometryCollection(‘c_geometry_collection’);
    14. $table->geometry(‘c_geometry’);
    15. $table->integer(‘c_integer’);
    16. $table->ipAddress(‘c_ip_address’);
    17. $table->json(‘c_json’);
    18. $table->jsonb(‘c_jsonb’);
    19. $table->lineString(‘c_line_string’);
    20. $table->longText(‘c_long_text’);
    21. $table->macAddress(‘c_mac_address’);
    22. $table->mediumInteger(‘c_medium_integer’);
    23. $table->mediumText(‘c_medium_text’);
    24. $table->morphs(‘c_morphs’);
    25. $table->multiLineString(‘c_multi_line_string’);
    26. $table->multiPoint(‘c_multi_point’);
    27. $table->multiPolygon(‘c_multi_polygon’);
    28. $table->point(‘c_point’);
    29. $table->polygon(‘c_polygon’);
    30. $table->rememberToken();
    31. $table->set(‘c_set’, [‘value1’, ‘value2’]);
    32. $table->smallInteger(‘c_small_integer’);
    33. $table->string(‘c_string’, 100);
    34. $table->text(‘c_text’);
    35. $table->timeTz(‘c_timetz’, $precision = 0);
    36. $table->time(‘c_time’, $precision = 0);
    37. $table->timestampTz(‘c_timestamptz’, $precision = 0);
    38. $table->timestamp(‘c_timestamp’, $precision = 0);
    39. $table->tinyInteger(‘c_tiny_integer’);
    40. $table->unsignedBigInteger(‘c_unsigned_big_integer’);
    41. $table->unsignedDecimal(‘c_unsigned_decimal’, $precision = 8, $scale = 2);
    42. $table->unsignedInteger(‘c_unsigned_integer’);
    43. $table->unsignedMediumInteger(‘c_unsigned_medium_integer’);
    44. $table->unsignedSmallInteger(‘c_unsigned_small_integer’);
    45. $table->unsignedTinyInteger(‘c_unsigned_tiny_integer’);
    46. $table->uuidMorphs(‘c_uuid_morphs’);
    47. $table->uuid(‘c_uuid’);
    48. $table->year(‘c_year’);
    49. $table->softDeletes($column = ‘deleted_at’, $precision = 0);
    50. $table->timestampsTz($precision = 0);
  2. 作業ログ
    1. 型の補足

型の対応

$table->bigIncrements(‘id’);

+---------------------------+------------------------------+------+-----+---------+----------------+
| Field                     | Type                         | Null | Key | Default | Extra          |
+---------------------------+------------------------------+------+-----+---------+----------------+
| id                        | bigint(20) unsigned          | NO   | PRI | NULL    | auto_increment |

$table->bigInteger(‘c_bigint’);

+---------------------------+------------------------------+------+-----+---------+----------------+
| Field                     | Type                         | Null | Key | Default | Extra          |
+---------------------------+------------------------------+------+-----+---------+----------------+
| c_bigint                  | bigint(20)                   | NO   |     | NULL    |                |

$table->binary(‘c_binary’);

+---------------------------+------------------------------+------+-----+---------+----------------+
| Field                     | Type                         | Null | Key | Default | Extra          |
+---------------------------+------------------------------+------+-----+---------+----------------+
| c_binary                  | blob                         | NO   |     | NULL    |                |

$table->boolean(‘c_boolean’);

+---------------------------+------------------------------+------+-----+---------+----------------+
| Field                     | Type                         | Null | Key | Default | Extra          |
+---------------------------+------------------------------+------+-----+---------+----------------+
| c_boolean                 | tinyint(1)                   | NO   |     | NULL    |                |

$table->char(‘c_char’, 100);

+---------------------------+------------------------------+------+-----+---------+----------------+
| Field                     | Type                         | Null | Key | Default | Extra          |
+---------------------------+------------------------------+------+-----+---------+----------------+
| c_char                    | char(100)                    | NO   |     | NULL    |                |

$table->date(‘c_date’);

+---------------------------+------------------------------+------+-----+---------+----------------+
| Field                     | Type                         | Null | Key | Default | Extra          |
+---------------------------+------------------------------+------+-----+---------+----------------+
| c_date                    | date                         | NO   |     | NULL    |                |

$table->dateTimeTz(‘c_datetimetz’, $precision = 0);

+---------------------------+------------------------------+------+-----+---------+----------------+
| Field                     | Type                         | Null | Key | Default | Extra          |
+---------------------------+------------------------------+------+-----+---------+----------------+
| c_datetimetz              | datetime                     | NO   |     | NULL    |                |

$table->decimal(‘c_decimal’, $precision = 8, $scale = 2);

+---------------------------+------------------------------+------+-----+---------+----------------+
| Field                     | Type                         | Null | Key | Default | Extra          |
+---------------------------+------------------------------+------+-----+---------+----------------+
| c_decimal                 | decimal(8,2)                 | NO   |     | NULL    |                |

$table->double(‘c_double’, 8, 2);

+---------------------------+------------------------------+------+-----+---------+----------------+
| Field                     | Type                         | Null | Key | Default | Extra          |
+---------------------------+------------------------------+------+-----+---------+----------------+
| c_double                  | double(8,2)                  | NO   |     | NULL    |                |

$table->enum(‘c_enum’, [‘easy’, ‘normal’, ‘hard’]);

+---------------------------+------------------------------+------+-----+---------+----------------+
| Field                     | Type                         | Null | Key | Default | Extra          |
+---------------------------+------------------------------+------+-----+---------+----------------+
| c_enum                    | enum('easy','normal','hard') | NO   |     | NULL    |                |

$table->float(‘c_float’, 8, 2);

+---------------------------+------------------------------+------+-----+---------+----------------+
| Field                     | Type                         | Null | Key | Default | Extra          |
+---------------------------+------------------------------+------+-----+---------+----------------+
| c_float                   | double(8,2)                  | NO   |     | NULL    |                |

$table->foreignId(‘c_foreignid’);

+---------------------------+------------------------------+------+-----+---------+----------------+
| Field                     | Type                         | Null | Key | Default | Extra          |
+---------------------------+------------------------------+------+-----+---------+----------------+
| c_foreignid               | bigint(20) unsigned          | NO   |     | NULL    |                |

$table->geometryCollection(‘c_geometry_collection’);

+---------------------------+------------------------------+------+-----+---------+----------------+
| Field                     | Type                         | Null | Key | Default | Extra          |
+---------------------------+------------------------------+------+-----+---------+----------------+
| c_geometry_collection     | geometrycollection           | NO   |     | NULL    |                |

$table->geometry(‘c_geometry’);

+---------------------------+------------------------------+------+-----+---------+----------------+
| Field                     | Type                         | Null | Key | Default | Extra          |
+---------------------------+------------------------------+------+-----+---------+----------------+
| c_geometry                | geometry                     | NO   |     | NULL    |                |

$table->integer(‘c_integer’);

+---------------------------+------------------------------+------+-----+---------+----------------+
| Field                     | Type                         | Null | Key | Default | Extra          |
+---------------------------+------------------------------+------+-----+---------+----------------+
| c_integer                 | int(11)                      | NO   |     | NULL    |                |

$table->ipAddress(‘c_ip_address’);

+---------------------------+------------------------------+------+-----+---------+----------------+
| Field                     | Type                         | Null | Key | Default | Extra          |
+---------------------------+------------------------------+------+-----+---------+----------------+
| c_ip_address              | varchar(45)                  | NO   |     | NULL    |                |

$table->json(‘c_json’);

+---------------------------+------------------------------+------+-----+---------+----------------+
| Field                     | Type                         | Null | Key | Default | Extra          |
+---------------------------+------------------------------+------+-----+---------+----------------+
| c_json                    | json                         | NO   |     | NULL    |                |

$table->jsonb(‘c_jsonb’);

+---------------------------+------------------------------+------+-----+---------+----------------+
| Field                     | Type                         | Null | Key | Default | Extra          |
+---------------------------+------------------------------+------+-----+---------+----------------+
| c_jsonb                   | json                         | NO   |     | NULL    |                |

$table->lineString(‘c_line_string’);

+---------------------------+------------------------------+------+-----+---------+----------------+
| Field                     | Type                         | Null | Key | Default | Extra          |
+---------------------------+------------------------------+------+-----+---------+----------------+
| c_line_string             | linestring                   | NO   |     | NULL    |                |

$table->longText(‘c_long_text’);

+---------------------------+------------------------------+------+-----+---------+----------------+
| Field                     | Type                         | Null | Key | Default | Extra          |
+---------------------------+------------------------------+------+-----+---------+----------------+
| c_long_text               | longtext                     | NO   |     | NULL    |                |

$table->macAddress(‘c_mac_address’);

+---------------------------+------------------------------+------+-----+---------+----------------+
| Field                     | Type                         | Null | Key | Default | Extra          |
+---------------------------+------------------------------+------+-----+---------+----------------+
| c_mac_address             | varchar(17)                  | NO   |     | NULL    |                |

$table->mediumInteger(‘c_medium_integer’);

+---------------------------+------------------------------+------+-----+---------+----------------+
| Field                     | Type                         | Null | Key | Default | Extra          |
+---------------------------+------------------------------+------+-----+---------+----------------+
| c_medium_integer          | mediumint(9)                 | NO   |     | NULL    |                |

$table->mediumText(‘c_medium_text’);

+---------------------------+------------------------------+------+-----+---------+----------------+
| Field                     | Type                         | Null | Key | Default | Extra          |
+---------------------------+------------------------------+------+-----+---------+----------------+
| c_medium_text             | mediumtext                   | NO   |     | NULL    |                |

$table->morphs(‘c_morphs’);

+---------------------------+------------------------------+------+-----+---------+----------------+
| Field                     | Type                         | Null | Key | Default | Extra          |
+---------------------------+------------------------------+------+-----+---------+----------------+
| c_morphs_type             | varchar(255)                 | NO   | MUL | NULL    |                |
| c_morphs_id               | bigint(20) unsigned          | NO   |     | NULL    |                |

$table->multiLineString(‘c_multi_line_string’);

+---------------------------+------------------------------+------+-----+---------+----------------+
| Field                     | Type                         | Null | Key | Default | Extra          |
+---------------------------+------------------------------+------+-----+---------+----------------+
| c_multi_line_string       | multilinestring              | NO   |     | NULL    |                |

$table->multiPoint(‘c_multi_point’);

+---------------------------+------------------------------+------+-----+---------+----------------+
| Field                     | Type                         | Null | Key | Default | Extra          |
+---------------------------+------------------------------+------+-----+---------+----------------+
| c_multi_point             | multipoint                   | NO   |     | NULL    |                |

$table->multiPolygon(‘c_multi_polygon’);

+---------------------------+------------------------------+------+-----+---------+----------------+
| Field                     | Type                         | Null | Key | Default | Extra          |
+---------------------------+------------------------------+------+-----+---------+----------------+
| c_multi_polygon           | multipolygon                 | NO   |     | NULL    |                |

$table->point(‘c_point’);

+---------------------------+------------------------------+------+-----+---------+----------------+
| Field                     | Type                         | Null | Key | Default | Extra          |
+---------------------------+------------------------------+------+-----+---------+----------------+
| c_point                   | point                        | NO   |     | NULL    |                |

$table->polygon(‘c_polygon’);

+---------------------------+------------------------------+------+-----+---------+----------------+
| Field                     | Type                         | Null | Key | Default | Extra          |
+---------------------------+------------------------------+------+-----+---------+----------------+
| c_polygon                 | polygon                      | NO   |     | NULL    |                |

$table->rememberToken();

+---------------------------+------------------------------+------+-----+---------+----------------+
| Field                     | Type                         | Null | Key | Default | Extra          |
+---------------------------+------------------------------+------+-----+---------+----------------+
| remember_token            | varchar(100)                 | YES  |     | NULL    |                |

$table->set(‘c_set’, [‘value1’, ‘value2’]);

+---------------------------+------------------------------+------+-----+---------+----------------+
| Field                     | Type                         | Null | Key | Default | Extra          |
+---------------------------+------------------------------+------+-----+---------+----------------+
| c_set                     | set('value1','value2')       | NO   |     | NULL    |                |

$table->smallInteger(‘c_small_integer’);

+---------------------------+------------------------------+------+-----+---------+----------------+
| Field                     | Type                         | Null | Key | Default | Extra          |
+---------------------------+------------------------------+------+-----+---------+----------------+
| c_small_integer           | smallint(6)                  | NO   |     | NULL    |                |

$table->string(‘c_string’, 100);

+---------------------------+------------------------------+------+-----+---------+----------------+
| Field                     | Type                         | Null | Key | Default | Extra          |
+---------------------------+------------------------------+------+-----+---------+----------------+
| c_string                  | varchar(100)                 | NO   |     | NULL    |                |

$table->text(‘c_text’);

+---------------------------+------------------------------+------+-----+---------+----------------+
| Field                     | Type                         | Null | Key | Default | Extra          |
+---------------------------+------------------------------+------+-----+---------+----------------+
| c_text                    | text                         | NO   |     | NULL    |                |

$table->timeTz(‘c_timetz’, $precision = 0);

+---------------------------+------------------------------+------+-----+---------+----------------+
| Field                     | Type                         | Null | Key | Default | Extra          |
+---------------------------+------------------------------+------+-----+---------+----------------+
| c_timetz                  | time                         | NO   |     | NULL    |                |

$table->time(‘c_time’, $precision = 0);

+---------------------------+------------------------------+------+-----+---------+----------------+
| Field                     | Type                         | Null | Key | Default | Extra          |
+---------------------------+------------------------------+------+-----+---------+----------------+
| c_time                    | time                         | NO   |     | NULL    |                |

$table->timestampTz(‘c_timestamptz’, $precision = 0);

+---------------------------+------------------------------+------+-----+---------+----------------+
| Field                     | Type                         | Null | Key | Default | Extra          |
+---------------------------+------------------------------+------+-----+---------+----------------+
| c_timestamptz             | timestamp                    | NO   |     | NULL    |                |

$table->timestamp(‘c_timestamp’, $precision = 0);

+---------------------------+------------------------------+------+-----+---------+----------------+
| Field                     | Type                         | Null | Key | Default | Extra          |
+---------------------------+------------------------------+------+-----+---------+----------------+
| c_timestamp               | timestamp                    | NO   |     | NULL    |                |

$table->tinyInteger(‘c_tiny_integer’);

+---------------------------+------------------------------+------+-----+---------+----------------+
| Field                     | Type                         | Null | Key | Default | Extra          |
+---------------------------+------------------------------+------+-----+---------+----------------+
| c_tiny_integer            | tinyint(4)                   | NO   |     | NULL    |                |

$table->unsignedBigInteger(‘c_unsigned_big_integer’);

+---------------------------+------------------------------+------+-----+---------+----------------+
| Field                     | Type                         | Null | Key | Default | Extra          |
+---------------------------+------------------------------+------+-----+---------+----------------+
| c_unsigned_big_integer    | bigint(20) unsigned          | NO   |     | NULL    |                |

$table->unsignedDecimal(‘c_unsigned_decimal’, $precision = 8, $scale = 2);

+---------------------------+------------------------------+------+-----+---------+----------------+
| Field                     | Type                         | Null | Key | Default | Extra          |
+---------------------------+------------------------------+------+-----+---------+----------------+
| c_unsigned_decimal        | decimal(8,2) unsigned        | NO   |     | NULL    |                |

$table->unsignedInteger(‘c_unsigned_integer’);

+---------------------------+------------------------------+------+-----+---------+----------------+
| Field                     | Type                         | Null | Key | Default | Extra          |
+---------------------------+------------------------------+------+-----+---------+----------------+
| c_unsigned_integer        | int(10) unsigned             | NO   |     | NULL    |                |

$table->unsignedMediumInteger(‘c_unsigned_medium_integer’);

+---------------------------+------------------------------+------+-----+---------+----------------+
| Field                     | Type                         | Null | Key | Default | Extra          |
+---------------------------+------------------------------+------+-----+---------+----------------+
| c_unsigned_medium_integer | mediumint(8) unsigned        | NO   |     | NULL    |                |

$table->unsignedSmallInteger(‘c_unsigned_small_integer’);

+---------------------------+------------------------------+------+-----+---------+----------------+
| Field                     | Type                         | Null | Key | Default | Extra          |
+---------------------------+------------------------------+------+-----+---------+----------------+
| c_unsigned_small_integer  | smallint(5) unsigned         | NO   |     | NULL    |                |

$table->unsignedTinyInteger(‘c_unsigned_tiny_integer’);

+---------------------------+------------------------------+------+-----+---------+----------------+
| Field                     | Type                         | Null | Key | Default | Extra          |
+---------------------------+------------------------------+------+-----+---------+----------------+
| c_unsigned_tiny_integer   | tinyint(3) unsigned          | NO   |     | NULL    |                |

$table->uuidMorphs(‘c_uuid_morphs’);

+---------------------------+------------------------------+------+-----+---------+----------------+
| Field                     | Type                         | Null | Key | Default | Extra          |
+---------------------------+------------------------------+------+-----+---------+----------------+
| c_uuid_morphs_type        | varchar(255)                 | NO   | MUL | NULL    |                |
| c_uuid_morphs_id          | char(36)                     | NO   |     | NULL    |                |

$table->uuid(‘c_uuid’);

+---------------------------+------------------------------+------+-----+---------+----------------+
| Field                     | Type                         | Null | Key | Default | Extra          |
+---------------------------+------------------------------+------+-----+---------+----------------+
| c_uuid                    | char(36)                     | NO   |     | NULL    |                |

$table->year(‘c_year’);

+---------------------------+------------------------------+------+-----+---------+----------------+
| Field                     | Type                         | Null | Key | Default | Extra          |
+---------------------------+------------------------------+------+-----+---------+----------------+
| c_year                    | year(4)                      | NO   |     | NULL    |                |

$table->softDeletes($column = ‘deleted_at’, $precision = 0);

+---------------------------+------------------------------+------+-----+---------+----------------+
| Field                     | Type                         | Null | Key | Default | Extra          |
+---------------------------+------------------------------+------+-----+---------+----------------+
| deleted_at                | timestamp                    | YES  |     | NULL    |                |

$table->timestampsTz($precision = 0);

+---------------------------+------------------------------+------+-----+---------+----------------+
| Field                     | Type                         | Null | Key | Default | Extra          |
+---------------------------+------------------------------+------+-----+---------+----------------+
| created_at                | timestamp                    | YES  |     | NULL    |                |
| updated_at                | timestamp                    | YES  |     | NULL    |                |

作業ログ

プロジェクトを生成後、設定ファイルをDBに接続できるように変更しておく。

$ composer create-project laravel/laravel sandbox --prefer-dist
$ cd sandbox
$ vi .env
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=sandbox
DB_USERNAME=sandbox
DB_PASSWORD='password'

テーブル作成用のmigrationを生成する。

$ php artisan make:migration create_sample_table
Created Migration: 2021_03_04_074713_create_sample_table
$ ls database/migrations/
2021_03_04_074713_create_sample_table.php
$ vi 2021_03_04_074713_create_sample_table.php

各型を記載したテーブルの定義は以下。

<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateSampleTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('sample', function (Blueprint $table) {
            $table->engine = 'InnoDB';
            $table->charset = 'utf8mb4';
            $table->collation = 'utf8mb4_unicode_ci';

            //$table->id(); $table->bigIncrementsと同じ
            //$table->increments('id'); unsignedInt
            $table->bigIncrements('id');
            $table->bigInteger('c_bigint');
            $table->binary('c_binary');
            $table->boolean('c_boolean');
            $table->char('c_char', 100);
            $table->date('c_date');
            $table->dateTimeTz('c_datetimetz', $precision = 0);
            $table->dateTime('c_datetime', $precision = 0);
            $table->decimal('c_decimal', $precision = 8, $scale = 2);
            $table->double('c_double', 8, 2);
            $table->enum('c_enum', ['easy', 'normal', 'hard']);
            $table->float('c_float', 8, 2);
            $table->foreignId('c_foreignid');
            $table->geometryCollection('c_geometry_collection');
            $table->geometry('c_geometry');
            $table->integer('c_integer');
            $table->ipAddress('c_ip_address');
            $table->json('c_json');
            $table->jsonb('c_jsonb');
            $table->lineString('c_line_string');
            $table->longText('c_long_text');
            $table->macAddress('c_mac_address');
            $table->mediumInteger('c_medium_integer');
            $table->mediumText('c_medium_text');
            $table->morphs('c_morphs');
            $table->multiLineString('c_multi_line_string');
            $table->multiPoint('c_multi_point');
            $table->multiPolygon('c_multi_polygon');
            $table->point('c_point');
            $table->polygon('c_polygon');
            $table->rememberToken();
            $table->set('c_set', ['value1', 'value2']);
            $table->smallInteger('c_small_integer');
            $table->string('c_string', 100);
            $table->text('c_text');
            $table->timeTz('c_timetz', $precision = 0);
            $table->time('c_time', $precision = 0);
            $table->timestampTz('c_timestamptz', $precision = 0);
            $table->timestamp('c_timestamp', $precision = 0);
            $table->tinyInteger('c_tiny_integer');
            $table->unsignedBigInteger('c_unsigned_big_integer');
            $table->unsignedDecimal('c_unsigned_decimal', $precision = 8, $scale = 2);
            $table->unsignedInteger('c_unsigned_integer');
            $table->unsignedMediumInteger('c_unsigned_medium_integer');
            $table->unsignedSmallInteger('c_unsigned_small_integer');
            $table->unsignedTinyInteger('c_unsigned_tiny_integer');
            $table->uuidMorphs('c_uuid_morphs');
            $table->uuid('c_uuid');
            $table->year('c_year');
            $table->softDeletes($column = 'deleted_at', $precision = 0);
            $table->timestampsTz($precision = 0);
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('sample');
    }
}

マイグレーションを実行。

$ php artisan migrate
Migration table created successfully.
Migrating: 2021_03_04_074713_create_sample_table
Migrated:  2021_03_04_074713_create_sample_table (692.29ms)

作成されたテーブルの内容は以下。

mysql> desc sample;
+---------------------------+------------------------------+------+-----+---------+----------------+
| Field                     | Type                         | Null | Key | Default | Extra          |
+---------------------------+------------------------------+------+-----+---------+----------------+
| id                        | bigint(20) unsigned          | NO   | PRI | NULL    | auto_increment |
| c_bigint                  | bigint(20)                   | NO   |     | NULL    |                |
| c_binary                  | blob                         | NO   |     | NULL    |                |
| c_boolean                 | tinyint(1)                   | NO   |     | NULL    |                |
| c_char                    | char(100)                    | NO   |     | NULL    |                |
| c_date                    | date                         | NO   |     | NULL    |                |
| c_datetimetz              | datetime                     | NO   |     | NULL    |                |
| c_datetime                | datetime                     | NO   |     | NULL    |                |
| c_decimal                 | decimal(8,2)                 | NO   |     | NULL    |                |
| c_double                  | double(8,2)                  | NO   |     | NULL    |                |
| c_enum                    | enum('easy','normal','hard') | NO   |     | NULL    |                |
| c_float                   | double(8,2)                  | NO   |     | NULL    |                |
| c_foreignid               | bigint(20) unsigned          | NO   |     | NULL    |                |
| c_geometry_collection     | geometrycollection           | NO   |     | NULL    |                |
| c_geometry                | geometry                     | NO   |     | NULL    |                |
| c_integer                 | int(11)                      | NO   |     | NULL    |                |
| c_ip_address              | varchar(45)                  | NO   |     | NULL    |                |
| c_json                    | json                         | NO   |     | NULL    |                |
| c_jsonb                   | json                         | NO   |     | NULL    |                |
| c_line_string             | linestring                   | NO   |     | NULL    |                |
| c_long_text               | longtext                     | NO   |     | NULL    |                |
| c_mac_address             | varchar(17)                  | NO   |     | NULL    |                |
| c_medium_integer          | mediumint(9)                 | NO   |     | NULL    |                |
| c_medium_text             | mediumtext                   | NO   |     | NULL    |                |
| c_morphs_type             | varchar(255)                 | NO   | MUL | NULL    |                |
| c_morphs_id               | bigint(20) unsigned          | NO   |     | NULL    |                |
| c_multi_line_string       | multilinestring              | NO   |     | NULL    |                |
| c_multi_point             | multipoint                   | NO   |     | NULL    |                |
| c_multi_polygon           | multipolygon                 | NO   |     | NULL    |                |
| c_point                   | point                        | NO   |     | NULL    |                |
| c_polygon                 | polygon                      | NO   |     | NULL    |                |
| remember_token            | varchar(100)                 | YES  |     | NULL    |                |
| c_set                     | set('value1','value2')       | NO   |     | NULL    |                |
| c_small_integer           | smallint(6)                  | NO   |     | NULL    |                |
| c_string                  | varchar(100)                 | NO   |     | NULL    |                |
| c_text                    | text                         | NO   |     | NULL    |                |
| c_timetz                  | time                         | NO   |     | NULL    |                |
| c_time                    | time                         | NO   |     | NULL    |                |
| c_timestamptz             | timestamp                    | NO   |     | NULL    |                |
| c_timestamp               | timestamp                    | NO   |     | NULL    |                |
| c_tiny_integer            | tinyint(4)                   | NO   |     | NULL    |                |
| c_unsigned_big_integer    | bigint(20) unsigned          | NO   |     | NULL    |                |
| c_unsigned_decimal        | decimal(8,2) unsigned        | NO   |     | NULL    |                |
| c_unsigned_integer        | int(10) unsigned             | NO   |     | NULL    |                |
| c_unsigned_medium_integer | mediumint(8) unsigned        | NO   |     | NULL    |                |
| c_unsigned_small_integer  | smallint(5) unsigned         | NO   |     | NULL    |                |
| c_unsigned_tiny_integer   | tinyint(3) unsigned          | NO   |     | NULL    |                |
| c_uuid_morphs_type        | varchar(255)                 | NO   | MUL | NULL    |                |
| c_uuid_morphs_id          | char(36)                     | NO   |     | NULL    |                |
| c_uuid                    | char(36)                     | NO   |     | NULL    |                |
| c_year                    | year(4)                      | NO   |     | NULL    |                |
| deleted_at                | timestamp                    | YES  |     | NULL    |                |
| created_at                | timestamp                    | YES  |     | NULL    |                |
| updated_at                | timestamp                    | YES  |     | NULL    |                |
+---------------------------+------------------------------+------+-----+---------+----------------+
54 rows in set (0.00 sec)

型の補足

text

midiumtext

enum

最大長65,535 (216 − 1) 文字のテキスト型。

最大長 16,777,215 (224 − 1) 文字のテキスト型。

定義した値のうちの一つを保持する。

set

定義した値のうちら一つ以上(複数可)を保持する。

point

緯度・経度の組み合わせを一つ保持する。地図で表すところの点。

linestring

緯度・経度の組み合わせを複数保持する。地図で表す所の線(2点をつないだもの)。

polygon

緯度・経度の組み合わせを複数保持する。地図で表す所の領域(複数の点をつないだもの)。

コメント

タイトルとURLをコピーしました