MySQL的auto_increment的基本特性和使用注意点

 时间:2024-10-13 05:20:53

1、打开Xshell,连接服务器并登陆到服务器,输入连接到MySQL

MySQL的auto_increment的基本特性和使用注意点

2、创建测试表,并指定字段为auto_increment,如下图所示create table test( id int not null auto_increment primary key, name varchar(10));

MySQL的auto_increment的基本特性和使用注意点

4、可以使用并通过alter table test auto_incremenrt=n语句来强制设置自动增长列的初始值。例如使用如下语句强制设置自增长初始值alter table test auto_incremenrt=4;insert into test values(null,'guanyu');

MySQL的auto_increment的基本特性和使用注意点

6、一个表嘀芟苒疾有且只能有一个auto_increment属性,自增长列必须是索引5.如果表中的auto_increment最大值被删除,不会被重用。即会巳鹞届蟑跳号mysql> select * from test;+----+------------+| id | name |+----+------------+| 1 | zhanghui || 2 | liubei || 3 | guanyu || 5 | shjhsdshjd |+----+------------+4 rows in set (0.00 sec)mysql> delete from test where id=5;Query OK, 1 row affected (0.01 sec)mysql>mysql> insert into test values(null,'machao');Query OK, 1 row affected (0.01 sec)mysql> select * from test;+----+----------+| id | name |+----+----------+| 1 | zhanghui || 2 | liubei || 3 | guanyu || 6 | machao |+----+----------+4 rows in set (0.00 sec)

MySQL的auto_increment的基本特性和使用注意点
  • AI怎么关闭印度语选项?
  • vegas如何给字幕添加渐变色?
  • AXURE如何避免网页中的图片失真?
  • AI如何使用套索、魔棒工具
  • AI如何原位复制形状
  • 热门搜索
    怎么查询微信注册时间 乐而雅卫生巾怎么样 虎皮鹦鹉怎么繁殖 平安惠普贷款怎么样 简历个人技能怎么写 怎么样才能瘦 分区助手怎么用 婧字怎么读 脸色发黄怎么调理 怎么玩股票