Insert random 100 million rows in DB-Table (MySQL / MariaDB)

Create DB Table:

CREATE TABLE `myVeryBigTable ` (
  `id` int(11) NOT NULL,
  `number` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;

 

Insert rows:


DELIMITER $$
CREATE PROCEDURE InsertRandomNumbers(IN InsertLimit INT, IN MinNumber INT, IN MaxNumber INT)
    BEGIN
        DECLARE i INT;
        SET i = 1;
        START TRANSACTION;
        WHILE i <= InsertLimit DO
            INSERT INTO myVeryBigTable VALUES (null, MinNumber + CEIL(RAND() * (MaxNumber - MinNumber)));
            SET i = i + 1;
        END WHILE;
        COMMIT;
    END$$
DELIMITER ;
CALL InsertRandomNumbers(10000, 1200300, 900800700);

 

Insert 100 millions:

CALL InsertRandomNumbers(100000000, 1200300, 900800700);

 

Neuen Kommentar schreiben

CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.

Suche

Neueste Kommentare