Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/234.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 自动增量列id不是从1开始的_Php_Database_Laravel_Migration - Fatal编程技术网

Php 自动增量列id不是从1开始的

Php 自动增量列id不是从1开始的,php,database,laravel,migration,Php,Database,Laravel,Migration,我有以下迁移: public function up() { Schema::create('players', function (Blueprint $table) { $table->increments('id'); $table->char('country_code',2); $table->integer('unoi_id'); $table->string('first_name');

我有以下迁移:

public function up()
{
    Schema::create('players', function (Blueprint $table) {
        $table->increments('id');
        $table->char('country_code',2);
        $table->integer('unoi_id');
        $table->string('first_name');
        $table->string('last_name');
        $table->char('gender', 1);
        $table->timestamp('birthdate');
        $table->integer('school_id');
        $table->string('school_period');
        $table->string('school_level');
        $table->integer('points');
        $table->timestamps();
    });
    Schema::table('players', function(Blueprint $table){
        $table->foreign('country_code')->references('country_code')->on('countries');
    });
}
创建新记录时,id列中的值不是从1开始的。它从321654开始,然后每次递增1

我的问题是:如何将默认值设置为1

// Your migration here:
Schema::create('players', function (Blueprint $table) {
    //
});

//then set auto-increment to 1000
DB::update("ALTER TABLE players AUTO_INCREMENT = 1000;");

请参阅:

您可以使用类似的内容

 ALTER table <table name> AUTO_INCREMENT = <initial value>

表格被截断,自动增量值不会重置。在下一个插入中,它将考虑下一个递增值,即使在这些情况下,我们可以执行上述查询来重置自动增量值

LaaLVEL有一个迁移新命令:迁移:新鲜是LaaVele: 5.5。Laravel当前的稳定版本是5.4谢谢。我从来没有想过直接使用mysql命令执行此操作。感谢您的帮助: