# MySQL function to generate random tinyint.ĬREATE FUNCTION get_tinyint() RETURNS INTEGER DETERMINISTIC # MySQL function to generate random int.ĬREATE FUNCTION get_int() RETURNS INTEGER DETERMINISTIC # MySQL function to generate random time.ĬREATE FUNCTION get_time() RETURNS INTEGER DETERMINISTIC #ěelow will generate random data for random years # MySQL function to generate random date (of year 2012).ĬREATE FUNCTION get_date() RETURNS VARCHAR(10) DETERMINISTIC RETURN round(rand()*pow(10,(in_precision-in_scale)),in_scale) # MySQL function to generate random float value from specified precision and scale.ĬREATE FUNCTION get_float(in_precision int, in_scale int) RETURNS VARCHAR(100) DETERMINISTIC # MySQL function to generate random Enum-ID from specified enum definitionĬREATE FUNCTION get_enum(col_type varchar(100)) RETURNS VARCHAR(100) DETERMINISTIC Download SQL for generating random data for foreign-key dependent child tables: populate_fk.sql How to install and generate dummy data: mysql -uUSER -pPASSWORD DATABASE 0) do Download the SQL code: Generate dummy data for MySQL.Ģ. Downloads Random Data Generator Tool For MySQL:ġ. Why can’t MySQL generate data for it’s own table when MySQL better knows the table than anyone else !!īelow are a set of functions and a stored procedure that will make our life easy and of-course it’s free. People can manage these things with a simple perl / shell script with loops but again that always need your time. Please consider reporting bugs and improvements. You can download the data generator tool for MySQL from Github for free. The tool will automatically generate the random data based on the table definition. I wrote combination of MySQL store routines and procedures that will generate the random test data for you without needing to specify table information. I hate generating dummy data, yes I do and I assume you do too! I think that’s the major reason I wrote these MySQL functions and procedures for Generating dummy test data. At-times you’ll write scripts to generate data but those will be table specific. There are tools that will generate random data for you but they’re not free. At times you’ll find yourself responsible for generating test data for newly created tables for testing or sampling purpose.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |