W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
數(shù)據(jù)庫結(jié)構(gòu)生成器包含構(gòu)建表時(shí)可以指定的各種字段類型:
命令 | 說明 |
---|---|
$table->id(); |
$table->bigIncrements('id') 的別名 |
$table->foreignId('user_id'); |
$table->unsignedBigInteger('user_id') 的別名 |
$table->bigIncrements('id'); |
遞增 ID(主鍵),相當(dāng)于「UNSIGNED BIG INTEGER」 |
$table->bigInteger('votes'); |
相當(dāng)于 BIGINT |
$table->binary('data'); |
相當(dāng)于 BLOB |
$table->boolean('confirmed'); |
相當(dāng)于 BOOLEAN |
$table->char('name', 100); |
相當(dāng)于帶有長度的 CHAR |
$table->date('created_at'); |
相當(dāng)于 DATE |
$table->dateTime('created_at', 0); |
相當(dāng)于 DATETIME ,可以指定位數(shù) |
$table->dateTimeTz('created_at', 0); |
相當(dāng)于 DATETIME (帶時(shí)區(qū)) ,可以指定位數(shù) |
$table->decimal('amount', 8, 2); |
相當(dāng)于 DECIMAL,可以指定總位數(shù)和小數(shù)位數(shù) |
$table->double('amount', 8, 2); |
相當(dāng)于 DOUBLE,可以指定總位數(shù)和小數(shù)位數(shù) |
$table->enum('level', ['easy', 'hard']); |
相當(dāng)于 ENUM |
$table->float('amount', 8, 2); |
相當(dāng)于 FLOAT,可以指定總位數(shù)和小數(shù)位數(shù) |
$table->geometry('positions'); |
相當(dāng)于 GEOMETRY |
$table->geometryCollection('positions'); |
相當(dāng)于 GEOMETRYCOLLECTION |
$table->increments('id'); |
遞增 ID(主鍵),相當(dāng)于 UNSIGNED INTEGER |
$table->integer('votes'); |
相當(dāng)于 INTEGER |
$table->ipAddress('visitor'); |
相當(dāng)于 IP 地址 |
$table->json('options'); |
相當(dāng)于 JSON |
$table->jsonb('options'); |
相當(dāng)于 JSONB |
$table->lineString('positions'); |
相當(dāng)于 LINESTRING |
$table->longText('description'); |
相當(dāng)于 LONGTEXT |
$table->macAddress('device'); |
相當(dāng)于 MAC 地址 |
$table->mediumIncrements('id'); |
遞增 ID(主鍵),相當(dāng)于 UNSIGNED MEDIUMINT |
$table->mediumInteger('votes'); |
相當(dāng)于 MEDIUMINT |
$table->mediumText('description'); |
相當(dāng)于 MEDIUMTEXT |
$table->morphs('taggable'); |
相當(dāng)于加入遞增 UNSIGNED BIGINT 類型的 taggable_id 與字符串類型的 taggable_type |
$table->uuidMorphs('taggable'); |
相當(dāng)于添加一個(gè) CHAR (36) 類型的 taggable_id 字段和 VARCHAR (255) UUID 類型的 taggable_type |
$table->multiLineString('positions'); |
相當(dāng)于 MULTILINESTRING |
$table->multiPoint('positions'); |
相當(dāng)于 MULTIPOINT |
$table->multiPolygon('positions'); |
相當(dāng)于 MULTIPOLYGON |
$table->nullableMorphs('taggable'); |
添加一個(gè)可以為空版本的 morphs() 字段. |
$table->nullableUuidMorphs('taggable'); |
添加一個(gè)可以為空版本的 uuidMorphs() 字段 |
$table->nullableTimestamps(0); |
timestamps() 方法的別名 |
$table->point('position'); |
相當(dāng)于 POINT |
$table->polygon('positions'); |
相當(dāng)于 POLYGON |
$table->rememberToken(); |
添加一個(gè)允許空值的 VARCHAR (100) 類型的 remember_token 字段 |
$table->set('flavors', ['strawberry', 'vanilla']); |
相當(dāng)于 SET |
$table->smallIncrements('id'); |
遞增 ID(主鍵),相當(dāng)于 UNSIGNED SMALLINT |
$table->smallInteger('votes'); |
相當(dāng)于 SMALLINT |
$table->softDeletes('deleted_at', 0); |
相當(dāng)于為軟刪除添加一個(gè)可空的 deleted_at 字段 |
$table->softDeletesTz('deleted_at', 0); |
相當(dāng)于為軟刪除添加一個(gè)可空的 帶時(shí)區(qū)的 deleted_at 字段 |
$table->string('name', 100); |
相當(dāng)于指定長度的 VARCHAR |
$table->text('description'); |
相當(dāng)于 TEXT |
$table->time('sunrise', 0); |
相當(dāng)于指定位數(shù)的 TIME |
$table->timeTz('sunrise', 0); |
相當(dāng)于指定位數(shù)帶時(shí)區(qū)的 TIME |
$table->timestamp('added_on', 0); |
相當(dāng)于指定位數(shù)的 TIMESTAMP |
$table->timestampTz('added_on', 0); |
相當(dāng)于指定位數(shù)帶時(shí)區(qū)的 TIMESTAMP |
$table->timestamps(0); |
相當(dāng)于添加可空的 TIMESTAMP 類型的 created_at 和 updated_at |
$table->timestampsTz(0); |
相當(dāng)于添加指定時(shí)區(qū)的可空的 TIMESTAMP 類型的 created_at 和 updated_at |
$table->tinyIncrements('id'); |
相當(dāng)于自動(dòng)遞增 UNSIGNED TINYINT |
$table->tinyInteger('votes'); |
相當(dāng)于 TINYINT |
$table->unsignedBigInteger('votes'); |
相當(dāng)于 UNSIGNED BIGINT |
$table->unsignedDecimal('amount', 8, 2); |
相當(dāng)于 UNSIGNED DECIMAL ,可以指定總位數(shù)和小數(shù)位數(shù) |
$table->unsignedInteger('votes'); |
相當(dāng)于 UNSIGNED INTEGER |
$table->unsignedMediumInteger('votes'); |
相當(dāng)于 UNSIGNED MEDIUMINT |
$table->unsignedSmallInteger('votes'); |
相當(dāng)于 UNSIGNED SMALLINT |
$table->unsignedTinyInteger('votes'); |
相當(dāng)于 UNSIGNED TINYINT |
$table->uuid('id'); |
相當(dāng)于 UUID |
$table->year('birth_year'); |
相當(dāng)于 YEAR |
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: