I am not experienced in this area. Can you tell me why autoincrement skips values?
This is my table:
CREATE TABLE `orders`
(
`id` int NOT NULL AUTO_INCREMENT,
`product_id` int NOT NULL,
`branch_offices_id` int NOT NULL,
`product_queue` int NOT NULL,
`quantity` int DEFAULT NULL,
`curdate` date NOT NULL,
`active` int NOT NULL DEFAULT '1',
`del` int NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
Here is the SQL query
INSERT INTO orders (branch_offices_id, product_id, product_queue,quantity,curdate)
SELECT
1 AS branch_offices_id,
id, queue, 0 AS quantity, CURDATE()
FROM
Product
There are no server restarts during and between insert requests, there are no triggers or stored procedures.
I run the code (that I showed) manually through mysql workbench
(I just change manually the branch_offices_id
values 1,2,3 ... etc in SELECT
statement),
There were no crashes, All fields received from SELECT are recorded.
15 missing values appear before reinserting.
enter image description here