当前位置:网站首页>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,'沁沁');
边栏推荐
- 第三章 : redis数据结构种类
- FPGA:基础入门按键控制LED灯
- 反射修改jsessionid实现Session共享
- 2022 Hangzhou Electric Power Multi-School Session 6 1008.Shinobu Loves Segment Tree Regular Questions
- MySQL data view
- 数据可视化(二)
- Data Middle Office Construction (10): Data Security Management
- 【 temperature warning program DE development 】 event driven model instance
- Getting started with Polkadot parachain development, this article is enough
- Opencv算术操作
猜你喜欢

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

还在找网盘资源吗?快点收藏如下几个值得收藏的网盘资源搜索神器吧!

Confessing in the era of digital transformation: Mai Cong Software allows enterprises to use data in the easiest way

Our Web3 Entrepreneurship Project, Yellow

一文道清什么是SPL

Complete image segmentation efficiently based on MindSpore and realize Dice!

SQL Outer Join Intersection, Union, Difference Query

多线程(进阶) - 2.5w字总结

The JVM collection that Alibaba's top architects have summarized for many years, where can't I check it!

告白数字化转型时代:麦聪软件以最简单的方式让企业把数据用起来
随机推荐
Dynamics 365Online PDF导出及打印
Go compilation principle series 6 (type checking)
【MindSpore Easy-Diantong Robot-01】You may have seen many knowledge quiz robots, but this one is a bit different
2022杭电多校 第6场 1008.Shinobu Loves Segment Tree 规律题
企业的数字化转型到底是否可以买来?
导火索:OAuth 2.0四种授权登录方式必读
SQL Outer Join Intersection, Union, Difference Query
FPGA:开发环境Vivado的使用
Is digital transformation a business buy-in?
What is SPL?
Jenkins manual (2) - software configuration
R语言ggplot2可视化:可视化密度图(Density plot)、可视化多个分组的密度图、数据点分布在箱图中间、添加主标题、副标题、题注信息
Ali's new launch: Microservices Assault Manual, all operations are written out in PDF
第三章 : redis数据结构种类
第五章:activiti流程分流判断,判断走不同的任务节点
Common operations of oracle under linux and daily accumulation of knowledge points (functions, timed tasks)
[Android]如何使用RecycleView in Kotlin project
How does the official account operate and maintain?Public account operation and maintenance professional team
JS introduction to reverse the recycling business network of learning, simple encryption mobile phone number
产品太多了,如何实现一次登录多产品互通?