innodb對於update,insert,delete關於auto_incremant的影響
innodb對於update,insert,delete關於auto_incremant的影響
mysql> create table inc_innodb (id int auto_increment primary key,name varchar(10)) engine=innodb;
Query OK, 0 rows affected (0.00 sec)
mysql> insert into inc_innodb (name) values ('name1');
Query OK, 1 row affected (0.00 sec)
mysql> insert into inc_innodb (name) values ('name22');
Query OK, 1 row affected (0.00 sec)
mysql> show create table inc_innodb;
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| inc_innodb | CREATE TABLE `inc_innodb` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(10) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 |
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> insert into inc_innodb values (4,'name4');
Query OK, 1 row affected (0.01 sec)
mysql> select * from inc_innodb;
+----+--------+
| id | name |
+----+--------+
| 1 | name1 |
| 2 | name22 |
| 4 | name4 |
+----+--------+
3 rows in set (0.00 sec)
mysql> show create table inc_innodb;
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| inc_innodb | CREATE TABLE `inc_innodb` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(10) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 |
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> update inc_innodb set id=10 where id=4;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> show create table inc_innodb;
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| inc_innodb | CREATE TABLE `inc_innodb` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(10) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 |
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> delete from inc_innodb where id=10;
Query OK, 1 row affected (0.00 sec)
mysql> show create table inc_innodb;
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| inc_innodb | CREATE TABLE `inc_innodb` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(10) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 |
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
對於innodb來說,insert來說 都會把 AUTO_INCREMENT的值升上去,
update不會把AUTO_INCREMENT值升上去
但是delete不會把AUTO_INCREMENT的值降下去。
轉載請註明源出處
QQ 273002188 歡迎一起學習
QQ 群 236941212
oracle,mysql,mongo 相互交流
相關:
http://blog.itpub.net/25099483/viewspace-1869360/
mysql> create table inc_innodb (id int auto_increment primary key,name varchar(10)) engine=innodb;
Query OK, 0 rows affected (0.00 sec)
mysql> insert into inc_innodb (name) values ('name1');
Query OK, 1 row affected (0.00 sec)
mysql> insert into inc_innodb (name) values ('name22');
Query OK, 1 row affected (0.00 sec)
mysql> show create table inc_innodb;
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| inc_innodb | CREATE TABLE `inc_innodb` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(10) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 |
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> insert into inc_innodb values (4,'name4');
Query OK, 1 row affected (0.01 sec)
mysql> select * from inc_innodb;
+----+--------+
| id | name |
+----+--------+
| 1 | name1 |
| 2 | name22 |
| 4 | name4 |
+----+--------+
3 rows in set (0.00 sec)
mysql> show create table inc_innodb;
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| inc_innodb | CREATE TABLE `inc_innodb` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(10) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 |
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> update inc_innodb set id=10 where id=4;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> show create table inc_innodb;
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| inc_innodb | CREATE TABLE `inc_innodb` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(10) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 |
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> delete from inc_innodb where id=10;
Query OK, 1 row affected (0.00 sec)
mysql> show create table inc_innodb;
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| inc_innodb | CREATE TABLE `inc_innodb` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(10) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 |
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
對於innodb來說,insert來說 都會把 AUTO_INCREMENT的值升上去,
update不會把AUTO_INCREMENT值升上去
但是delete不會把AUTO_INCREMENT的值降下去。
轉載請註明源出處
QQ 273002188 歡迎一起學習
QQ 群 236941212
oracle,mysql,mongo 相互交流
相關:
http://blog.itpub.net/25099483/viewspace-1869360/
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/25099483/viewspace-1869361/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- MySQL 關於 INSERT INTO...ON DUPLICATE KEY UPDATE 的使用MySql
- 關於OPcache對Swoole影響的理解opcache
- sql server 帶有OUTPUT的INSERT,DELETE,UPDATESQLServerdelete
- java-Mybatis XML 對映器(select,insert, update 和 delete)JavaMyBatisXMLdelete
- SQLite語句(二):INSERT DELETE UPDATE SELECTSQLitedelete
- mysql 在delete、insert、update 時,page的變化MySqldelete
- DBeaver如何生成select,update,delete,insert語句delete
- 利用insert,update和delete注入獲取資料delete
- KunlunDB功能之insert/update/delete...returning語句delete
- SQL Server的Merge —— 一步實現 insert,update,deleteSQLServerdelete
- 輕量ORM-SqlRepoEx (四)INSERT、UPDATE、DELETE 語句ORMSQLdelete
- 關於資料庫開啟大頁對效能的影響資料庫
- 關於LOL成就係統對玩家影響的簡略分析
- 遊戲暗示對於遊戲玩家的影響遊戲
- Sqlserver update\delete用inner join關聯,會update\delete關鍵字後面的表關聯到的行SQLServerdelete
- 小記: 關於CSS display 屬性對錶格語義的影響CSS
- 元宇宙技術對於虛擬模擬應用的影響元宇宙
- MySQL:Innodb:innodb_flush_log_at_trx_commit引數影響的位置MySqlMIT
- Sqlserver、oracle中Merge的使用方法,一個merge語句搞定多個Insert,Update,Delete操作SQLServerOracledelete
- 人工智慧對於IT行業的從業者影響分析報告人工智慧行業
- 標準模式與怪異模式對於渲染頁面的影響模式
- 伺服器對於網站最佳化是否有影響伺服器網站
- MySQL InnoDB update流程MySql
- MyBatis(五) insert、update、delete 、主鍵回填、返回matched行數和affected行數、引數配置#{},${}MyBatisdelete
- 時區以及時區對於Java時間類格式化的影響Java
- 380. Insert Delete GetRandom O (1)deleterandom
- 智慧數字化轉型對於餐飲業有哪些影響?
- 關於對Host的理解
- 關於COVID-19和基本供應鏈自動化的影響的思考
- 在After Insert觸發器中使用INSERT後,影響SCOPE_IDENTITY 問題觸發器IDE
- 微信小商店的開發,對於社交電商有什麼影響?
- 數字經濟對於製造業數字化轉型影響的思考
- 【恩墨學院】深入解讀Oracle 18c對於DBA的影響及應對措施Oracle
- 關於SVN update之後,引起衝突的解決方法
- [LeetCode] 380. Insert Delete GetRandom O(1)LeetCodedeleterandom
- 關於Warning: setState(...): Can only update a mounted or mounting component. This
- mysql update join,insert select 語法MySql
- MySQL insert on duplicate key update 死鎖MySql
- MySQL:Innodb 關於Handler_commit每次DML增加2的原因MySqlMIT