qadenza
qadenza

Reputation: 9293

How to insert a batch of empty rows without forloop?

create table arts (
    `id` int(11) auto_increment,
    `pass` int,
    `name` varchar(255),
    `price` decimal(11,2),
    primary key (`id`)
) engine = innodb, charset utf8mb4 collate utf8mb4_croatian_ci;

How can I insert 4000 empty rows inside the above table, using mysql?

Thanks.

Upvotes: 3

Views: 55

Answers (1)

D-Shih
D-Shih

Reputation: 46239

You can try to use INSERT INTO with CROSS JOIN ... limit your number.

INSERT INTO arts (pass,name,price)
SELECT NULL,NULL,NULL
FROM INFORMATION_SCHEMA.COLUMNS t1
CROSS JOIN INFORMATION_SCHEMA.COLUMNS  t2
LIMIT 4000

Results:

Upvotes: 1

Related Questions