Blog Archives

Generating random data with MySQL

Posted in Inside TFG

I’m doing some modifications to a Copper installation for a customer that involved the addition of some new fields to their project table, namely CashContribution and InKind. They both track different donation types that can be made against a project.

I needed a quick way to populate some projects with dummy, random data, and here’s what I ended up with:

UPDATE Projects
SET CashContribution = (SELECT CONVERT(RAND() * 1000, UNSIGNED))
WHERE ID > 600;

This meant that I wasn’t looking at row-after-row of the same dummy data, and that the test system better represents the intended real-world use.

Twitter

The latest @rubyfive podcast is up, our own @sj26 receiving a mention for Ruby 1.9.3 performance improvements. http://t.co/hfx3EPMz

@frontiergroup about 1 day ago #

Search Posts

Featured Posts

Categories

Archives

View more archives