Master Yoda Master Yoda - 6 months ago 34
SQL Question

how to create fake DATA inside MariaDB SQL database?

I am trying to create some TEST DATA, meaning fake data for playing around with MariaDB tables and databases.

I need to create some fake random data using SQL RDBMS. So, why not use Mockaroo.com , but on that website I can only do 1000 rows at one time. Which is extremely time consuming.

How can I create random fake data. Tons of it. For example, Let us say I want 2 millions rows of random data with ID, NAME, ADDRESS, PHONE, EMAIL.

I hope I am making sense. Any help is greatly appreciated!!!!!

Linux Newbie - Information is Power! Download Linux @ http://www.fedora.redhat.com/

May the Linux force be with you!

Answer

YES,

you can do it very easy with MariaDB:

The is a sequence Engine, thats what you need.

Here a sample

This Sample will store the data (created with the SELECT) in the table "yourtable".

INSERT INTO yourtable
SELECT seq,CONCAT('NAME FROM:',seq), CONCAT('ADR:',seq), CAST(RAND(SEQ)*10000000 AS INT),CONCAT(seq,'@dumymail.xx') FROM seq_1_to_1000000;

this will generate like this:

MariaDB [mysql]> SELECT seq,CONCAT('NAME FROM:',seq), CONCAT('ADR:',seq), CAST(RAND(SEQ)*10000000 AS INT),CONCAT(seq,'@dumymail.xx') FROM seq_1_to_10;
+-----+--------------------------+--------------------+---------------------------------+----------------------------+
| seq | CONCAT('NAME FROM:',seq) | CONCAT('ADR:',seq) | CAST(RAND(SEQ)*10000000 AS INT) | CONCAT(seq,'@dumymail.xx') |
+-----+--------------------------+--------------------+---------------------------------+----------------------------+
|   1 | NAME FROM:1              | ADR:1              |                         4054035 | 1@dumymail.xx              |
|   2 | NAME FROM:2              | ADR:2              |                         6555866 | 2@dumymail.xx              |
|   3 | NAME FROM:3              | ADR:3              |                         9057698 | 3@dumymail.xx              |
|   4 | NAME FROM:4              | ADR:4              |                         1559529 | 4@dumymail.xx              |
|   5 | NAME FROM:5              | ADR:5              |                         4061360 | 5@dumymail.xx              |
|   6 | NAME FROM:6              | ADR:6              |                         6563191 | 6@dumymail.xx              |
|   7 | NAME FROM:7              | ADR:7              |                         9065022 | 7@dumymail.xx              |
|   8 | NAME FROM:8              | ADR:8              |                         1566853 | 8@dumymail.xx              |
|   9 | NAME FROM:9              | ADR:9              |                         4068684 | 9@dumymail.xx              |
|  10 | NAME FROM:10             | ADR:10             |                         6570515 | 10@dumymail.xx             |
+-----+--------------------------+--------------------+---------------------------------+----------------------------+
10 rows in set (0.00 sec)

MariaDB [mysql]>