Created
September 10, 2022 02:37
-
-
Save yoku0825/bb8ce7f57e92e3800f8d9a1492038b27 to your computer and use it in GitHub Desktop.
Invisible auto_increment vs LAST_INSERT_ID
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mysql80 15> SHOW CREATE TABLE t1\G | |
*************************** 1. row *************************** | |
Table: t1 | |
Create Table: CREATE TABLE `t1` ( | |
`num` bigint unsigned NOT NULL AUTO_INCREMENT /*!80023 INVISIBLE */, | |
`val` varchar(32) COLLATE utf8mb4_ja_0900_as_cs DEFAULT NULL, | |
UNIQUE KEY `num` (`num`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_ja_0900_as_cs | |
1 row in set (0.00 sec) | |
mysql80 15> | |
mysql80 15> | |
mysql80 15> | |
mysql80 15> INSERT INTO t1 VALUES ('one'); | |
Query OK, 1 row affected (0.01 sec) | |
mysql80 15> SELECT LAST_INSERT_ID(); | |
+------------------+ | |
| LAST_INSERT_ID() | | |
+------------------+ | |
| 1 | | |
+------------------+ | |
1 row in set (0.00 sec) | |
mysql80 15> INSERT INTO t1 VALUES ('two'); | |
Query OK, 1 row affected (0.00 sec) | |
mysql80 15> SELECT LAST_INSERT_ID(); | |
+------------------+ | |
| LAST_INSERT_ID() | | |
+------------------+ | |
| 2 | | |
+------------------+ | |
1 row in set (0.00 sec) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment