I would like to be able to insert a large number of sequential records into a table with an AUTO_INCREMENT
field, setting the value of another field to a constant value for all the inserted rows, using a single query.
Example:
CREATE TABLE CardNumbers ( First15 BIGINT NOT NULL AUTO_INCREMENT, CheckDigit DECIMAL(1, 0) NOT NULL, PRIMARY KEY (First15) ) ENGINE=InnoDB AUTO_INCREMENT=123456789012345;
I would like to set the CheckDigit
to 0
for all of these to start, and then calculate it later from the First15
.
I imagine a query like:
INSERT INTO `CardNumbers` (CheckDigit)
SELECT 0 FROM (...) LIMIT 1000000;
Where (...)
creates an infinite set of rows or similar.