For a play application that I am working on, rather than to hardcode all of the data, it seems fitting to have the system generate some of the data itself.
For one particular integer column, I wanted random integer data.
BTW, my targeted database is running on MySQL.
Here is a simple SQL for generating random int.
- Drop function if it exists already
- Temporarily change delimiter from ; to //
- Create Function
- Revert delimiter to ;
DROP FUNCTION IF EXISTS funcRandom; delimiter // CREATE FUNCTION funcRandom ( low INT , high int ) RETURNS int DETERMINISTIC BEGIN RETURN ( floor ( rand() * ( ( high + 1 ) - ( low ) ) ) + low ); END; //