如何用口才在Laravel中设置AUTO_INCREMENT? [英] How to set AUTO_INCREMENT in Laravel with Eloquent?

查看:286
本文介绍了如何用口才在Laravel中设置AUTO_INCREMENT?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理一个应用程序,我的雇主希望用户表中的ID应该从100,000开始而不是1.它是Schema Builder本身中的参数吗?还是我必须在MySQL中设置一些内容?

I am working on an application and my employer wants that the id in the user table should begin from 100,000 instead of 1. How can accomplish that? Is it a parameter in the Schema Builder itself? Or would I have to set something in the MySQL instead?

推荐答案

您可以使用SQL本身来执行此操作. ALTER TABLE <table_name> AUTO_INCREMENT=100000;.

You can use SQL its self to do this. ALTER TABLE <table_name> AUTO_INCREMENT=100000;.

此处

并使用未准备好的语句;

And use a unprepared statement;

$statement = "ALTER TABLE MY_TABLE AUTO_INCREMENT = 100000;";

DB::unprepared($statement);

DB::update("ALTER TABLE {your table name} AUTO_INCREMENT = 100000;");

然后可以将其放在创建表的迁移中.

Which could then be put within the migration that creates the table.

这篇关于如何用口才在Laravel中设置AUTO_INCREMENT?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆