如何在MySQL中更改自动递增的起始数字?
来源:tutorialspoint
时间:2023-08-23 19:28:35 319浏览 收藏
IT行业相对于一般传统行业,发展更新速度更快,一旦停止了学习,很快就会被行业所淘汰。所以我们需要踏踏实实的不断学习,精进自己的技术,尤其是初学者。今天golang学习网给大家整理了《如何在MySQL中更改自动递增的起始数字?》,聊聊,我们一起来看看吧!
The auto_increment is a default property that automatically increments the newly added record by 1. The auto_increment can be changed from the beginning as well. The procedure for that is given below −
First, a table is created.
mysql> CREATE table DemoAuto -> ( -> id int auto_increment, -> name varchar(100), -> primary key(id) -> ); Query OK, 0 rows affected (0.47 sec)
After that the alter table command is used to change the starting number of auto_incremnt which starts from 1 by default. The starting value is changed to 100.
mysql> alter table DemoAuto auto_increment = 100; Query OK, 0 rows affected (0.24 sec) Records: 0 Duplicates: 0 Warnings: 0
Then some records are inserted into the table.This is given as follows −
mysql> INSERT into DemoAuto(name) values('John'); Query OK, 1 row affected (0.10 sec) mysql> INSERT into DemoAuto(name) values('Smith'); Query OK, 1 row affected (0.13 sec) mysql> INSERT into DemoAuto(name) values('Bob'); Query OK, 1 row affected (0.22 sec)
The select statement is used to obtain the table values as output. This is given below −
mysql> SELECT * from DemoAuto;
The following is the output obtained −
+-----+-------+ | id | name | +-----+-------+ | 100 | John | | 101 | Smith | | 102 | Bob | +-----+-------+ 3 rows in set (0.00 sec)
In the above output, the record id starts from 100.
今天关于《如何在MySQL中更改自动递增的起始数字?》的内容就介绍到这里了,是不是学起来一目了然!想要了解更多关于的内容请关注golang学习网公众号!
-
501 收藏
-
501 收藏
-
501 收藏
-
501 收藏
-
501 收藏
-
113 收藏
-
434 收藏
-
335 收藏
-
242 收藏
-
449 收藏
-
127 收藏
-
163 收藏
-
152 收藏
-
286 收藏
-
150 收藏
-
419 收藏
-
448 收藏
-
- 前端进阶之JavaScript设计模式
- 设计模式是开发人员在软件开发过程中面临一般问题时的解决方案,代表了最佳的实践。本课程的主打内容包括JS常见设计模式以及具体应用场景,打造一站式知识长龙服务,适合有JS基础的同学学习。
- 立即学习 542次学习
-
- GO语言核心编程课程
- 本课程采用真实案例,全面具体可落地,从理论到实践,一步一步将GO核心编程技术、编程思想、底层实现融会贯通,使学习者贴近时代脉搏,做IT互联网时代的弄潮儿。
- 立即学习 508次学习
-
- 简单聊聊mysql8与网络通信
- 如有问题加微信:Le-studyg;在课程中,我们将首先介绍MySQL8的新特性,包括性能优化、安全增强、新数据类型等,帮助学生快速熟悉MySQL8的最新功能。接着,我们将深入解析MySQL的网络通信机制,包括协议、连接管理、数据传输等,让
- 立即学习 497次学习
-
- JavaScript正则表达式基础与实战
- 在任何一门编程语言中,正则表达式,都是一项重要的知识,它提供了高效的字符串匹配与捕获机制,可以极大的简化程序设计。
- 立即学习 487次学习
-
- 从零制作响应式网站—Grid布局
- 本系列教程将展示从零制作一个假想的网络科技公司官网,分为导航,轮播,关于我们,成功案例,服务流程,团队介绍,数据部分,公司动态,底部信息等内容区块。网站整体采用CSSGrid布局,支持响应式,有流畅过渡和展现动画。
- 立即学习 484次学习