当前位置:网站首页>MySQL 中 auto_increment 自动插入主键值
MySQL 中 auto_increment 自动插入主键值
2022-08-05 10:28:00 【威威沁沁】
对于整数类型的主键,常搭配自增长 auto_increment 来使用。插入数据对应的字段不给值时,使用最大值+1!!
下面进行演示~~
1️⃣首先创建一个表
create table emp(id int primary key auto_increment , name varchar(20));注意:atuo_increment 只能作用在设置 主键 列上
2️⃣插入记录
当表中没记录时,我们把对应字段设置null,自动插入 id 的值从 1递增 !!
insert into emp values(null,'张三'),(null,'王五'),(null,'马六'); 
当表中有记录,自插入 id 值为表中最大值+1
insert into emp values(100,'威威');
insert into emp values(null,'沁沁');
边栏推荐
- SQL外连接之交集、并集、差集查询
- Common operations of oracle under linux and daily accumulation of knowledge points (functions, timed tasks)
- Meteorological data processing example - matlab string cutting matching and R language date matching (data splicing)
- 电气工程的标准是什么
- Getting started with Polkadot parachain development, this article is enough
- LeetCode 216. Combined Sum III (2022.08.04)
- SkiaSharp 之 WPF 自绘 投篮小游戏(案例版)
- FPGA:开发环境Vivado的使用
- 60行从零开始自己动手写FutureTask是什么体验?
- uniapp 连接ibeacon
猜你喜欢

登录功能和退出功能(瑞吉外卖)

基于MindSpore高效完成图像分割,实现Dice!

2022华数杯数学建模A题环形振荡器的优化设计思路思路代码分享

PCB布局必知必会:教你正确地布设运算放大器的电路板

Our Web3 Entrepreneurship Project, Yellow
![[强网杯2022]WP-UM](/img/3d/caeab05ddca278af274dbf6e2f8ba1.png)
[强网杯2022]WP-UM

Voice-based social software development - making the most of its value

linux下oracle常见操作以及日常积累知识点(函数、定时任务)

Login function and logout function (St. Regis Takeaway)

012_SSS_ Improving Diffusion Model Efficiency Through Patching
随机推荐
PCB layout must know: teach you to correctly lay out the circuit board of the op amp
Common operations of oracle under linux and daily accumulation of knowledge points (functions, timed tasks)
第四章:activiti流程中,变量的传递和获取流程变量 ,设置和获取多个流程变量,设置和获取局部流程变量「建议收藏」
Go compilation principle series 6 (type checking)
Meteorological data processing example - matlab string cutting matching and R language date matching (data splicing)
Jenkins manual (2) - software configuration
阿里顶级架构师多年总结的JVM宝典,哪里不会查哪里!
MySQL data view
创建一个 Dapp,为什么要选择波卡?
化繁为简!阿里新产亿级流量系统设计核心原理高级笔记(终极版)
What is SPL?
How does the official account operate and maintain?Public account operation and maintenance professional team
FPGA:开发环境Vivado的使用
Ali's new launch: Microservices Assault Manual, all operations are written out in PDF
七夕来袭!还要做CDH数据迁移怎么办?来看看DistCp
uniapp 连接ibeacon
技术干货 | 基于 MindSpore 实现图像分割之豪斯多夫距离
一文道清什么是SPL
Opencv图像缩放和平移
如何修改管理工具client_encoding