K
K
Kirill Novak2021-06-14 16:48:04
MySQL
Kirill Novak, 2021-06-14 16:48:04

Is there a way to automatically add all empty rows in MySQL with AUTO_INCREMENT up to some maximum value?

There is a table with default values ​​set. I just need to create a million autoincrement rows. Is there some simple way to do this? In fact, just create a million empty lines

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Akina, 2021-06-14
@kinojs

create a million empty strings

WITH RECURSIVE 
cte AS ( SELECT 1 n
         UNION ALL
         SELECT n + 1  FROM cte WHERE n < 1000 )
INSERT INTO tablename (id)
SELECT NULL FROM cte t1 CROSS JOIN cte t2;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question