<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                # Laravel 數據遷移字段類型&字段長度綜合表 ## 數值類型 | 命令 | 大小 | 描述 | 范圍 | 用途 | | --- | --- | --- | --- | --- | | $table->tinyInteger('votes'); | 1 字節 | 相當于 TINYINT | (-128,127) | 小整數值 | | $table->tinyIncrements('id'); | 1 字節 | 相當于 自動遞增 UNSIGNED TINYINT | (0,255) | 小整數值 | | $table->unsignedTinyInteger('votes'); | 1 字節 | 相當于 不遞增 UNSIGNED?TINYINT | (0,255) | 小整數值 | | $table->smallInteger('votes'); | 2 字節 | 相當于 SMALLINT | (-32 768,32 767) | 大整數值 | | $table->unsignedSmallInteger('votes'); | 2 字節 | 相當于 不遞增 UNSIGNED SMALLINT | (0,65 535) | 大整數值 | | $table->mediumInteger('votes'); | 3 字節 | 相當于 MEDIUMINT | (-8 388 608,8 388 607) | 大整數值 | | $table->unsignedMediumInteger('votes'); | 3 字節 | 相當于 Unsigned MEDIUMINT | (0,16 777 215) | 大整數值 | | $table->integer('votes'); | 4 字節 | 相當于 INTEGER | (-2 147 483 648,2 147 483 647) | 大整數值 | | $table->increments('id'); | 4 字節 | 遞增的 ID (主鍵),相當于「UNSIGNED INTEGER」 | (0,4 294 967 295) | 大整數值 | | $table->bigInteger('votes'); | 8 字節 | 相當于 BIGINT | (-9 233 372 036 854 775 808,9 223 372 036 854 775 807) | 極大整數值 | | $table->unsignedBigInteger('votes'); | 8 字節 | 相當于 UNSIGNED BIGINT | (0,18 446 744 073 709 551 615) | 極大整數值 | | $table->float('amount', 8, 2); | 4 字節 | 相當于帶有精度與基數 FLOAT | (-3.402 823 466 E+38,-1.175 494 351 E-38),0,(1.175 494 351 E-38,3.402 823 466 351 E+38) | 單精度 浮點數值 | | $table->double('column', 8, 2) | 8 字節 | 相當于帶有精度與基數 DOUBLE | (-1.797 693 134 862 315 7 E+308,-2.225 073 858 507 201 4 E-308),0,(2.225 073 858 507 201 4 E-308,1.797 693 134 862 315 7 E+308) | 雙精度,浮點數值 | | $table->decimal('amount', 8, 2); | 對DECIMAL(M,D) | 相當于帶有精度與基數 DECIMAL | 依賴于M和D的值 | 小數值 | ## 字符串類型 | 類型 | 大小 | 描述 | 用途 | | --- | --- | --- | --- | | $table->char('name', 4); | 0-255字節 | 相當于帶有長度的 CHAR | 定長字符串 | | $table->string('name', 100); | 0-65535 字節 | 相當于帶長度的 VARCHAR | 變長字符串 | | TINYBLOB | 0-255字節 | | 不超過 255 個字符的二進制字符串 | | TINYTEXT | 0-255字節 | | 短文本字符串 | | $table->binary('data'); | 0-65 535字節 | 相當于 BLOB | 二進制形式的長文本數據 | | $table->text('description'); | 0-65 535字節 | 相當于 TEXT | 長文本數據 | | MEDIUMBLOB | 0-16 777 215字節 | | 二進制形式的中等長度文本數據 | | $table->mediumText('description'); | 0-16 777 215字節 | 相當于 MEDIUMTEXT | 中等長度文本數據 | | LONGBLOB | 0-4 294 967 295字節 | | 二進制形式的極大文本數據 | | $table->longText('description'); | 0-4 294 967 295字節 | 相當于 LONGTEXT | 極大文本數據 | ## 日期和時間類型 | 命令 | 大小 | 描述 | 范圍 | 格式 | 用途 | | --- | --- | --- | --- | --- | --- | | $table->date('created\_at'); | 3字節 | 相當于 DATE | 1000-01-01/9999-12-31 | YYYY-MM-DD | 日期值 | | $table->time('sunrise'); | 3字節 | 相當于 TIME | '-838:59:59'/'838:59:59' | HH:MM:SS | 時間值或持續時間 | | $table->year('birth\_year'); | 1字節 | 相當于 YEAR | 1901/2155 | YYYY | 年份值 | | $table->dateTime('created\_at'); | 8字節 | 相當于 DATE | 1000-01-01 00:00:00/9999-12-31 23:59:59 | YYYY-MM-DD HH:MM:SS | 混合日期和時間值 | | $table->timestamp('added\_on'); | 4字節 | 相當于 TIMESTAMP | 1970-01-01 00:00:00/2038 結束時間是第?**2147483647**?秒,北京時間?**2038-1-19 11:14:07**,格林尼治時間 2038年1月19日 凌晨 03:14:07 | YYYYMMDD HHMMSS | 混合日期和時間值,時間戳 | //================================================================================= ~~~ /* 表引擎 */ $table->engine = 'InnoDB'; /* 類型 */ // - 數字 $table->bigInteger('id'); $table->integer('id'); $table->mediumInteger('id'); $table->smallInteger('id'); $table->tinyInteger('id'); $table->decimal('balance', 15, 8); $table->float('balance'); $table->double('balance', 15, 8); $table->real('balance'); // - 時間 $table->date('created_at'); $table->dateTime('created_at'); $table->timeStamp('created_at'); $table->time('sunrise'); // - 字符串 $table->char('name', 4); // 等同于 VARCHAR $table->string('name'); // 等同于 VARCHAR(100) $table->string('name', 100); $table->text('description'); $table->mediumText('description'); $table->longText('description'); // 等同于 BLOB $table->binary('data'); $table->enum('choices', ['foo', 'bar']); $table->boolean('confirmed'); // - 不經常用的 $table->json('options'); // 等同于數據庫中的 JSON 類型 $table->jsonb('options'); // 等同于數據庫中的 JSONB 類型 $table->uuid('id'); // 等同于數據庫的UUID // 自增ID,類型為 bigint $table->bigIncrements('id'); // 自增ID,類型為 int $table->increments('id'); // 添加一個 INTEGER類型的 taggable_id 列和一個 STRING類型的 taggable_type列 $table->morphs('taggable'); // 和 timestamps() 一樣,但允許 NULL 值 $table->nullableTimestamps('created_at'); // 添加一個 'remember_token' 列:VARCHAR(100) NULL $table->rememberToken(); // 添加 'created_at' 和 'updated_at' $table->timeStamps(); // 新增一個 'deleted_at' 列,用于 '軟刪除' $table->softDeletes(); /* 列修改器 */ ->first(); // 將列置于表第一個列(僅限于MYSQL) ->after('列名'); // 將列置于某一列后(僅限于MYSQL) ->nullable(); // 允許列為NULL ->defalut($value); // 指定列默認值 ->unsigned(); // 設置整型列為 UNSIGNED /* 修改列 需安裝 doctrine/dbal,composer require doctrine/dbal */ // change() - 修改列 $table->string('name', 30)->nullable()->change(); // renameColumn() - 重命名列 $table->renameColumn('name', 'title'); /* 刪除列 需安裝 doctrine/dbal,composer require doctrine/dbal */ // 刪除單個列 $table->dropColumn('name'); // 刪除多個列 $table->dropColumn(['name', 'age']); /* 創建索引 * 每種索引,都有3種方式: * 一個string參數 * 一個array參數 - 組合索引 * 2個參數 - 允許自定義索引名 * 注意: * laravel自動分配的索引名: * 表名_列名_索引類型:users_mobile_unique // users表的mobile字段為unique 索引 */ $table->primary('id'); // 主鍵索引 $table->primary(['first', 'last']); // 混合索引(這個不太清楚) $table->primary('first', 'first_primary_index']); // 自定義索引名 $table->unique('mobile'); // 唯一索引 $table->index('state'); // 普通索引 /* 刪除索引 */ $table->dropPrimary('索引名') $table->dropUnique('索引名') $table->dropIndex('索引名') /* 外鍵約束 * 注意: * laravel自動分配的外鍵名: * 表名_列名_foreign:posts_user_id_foreign // posts表的user_id字段添加foreign */ // 添加外鍵,當前表的user_id,外鍵關聯users表的id列 $table->foreign('user_id')->references('id')->on('users'); // 約束 'on delete' 和 'on update' 時,才關聯外鍵 $table->foreign('user_id')->references('id')->on('users')->onDelete; // 刪除外鍵 $table->dropForeign('posts_user_id_foreign'); ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看