create.sql 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. # modified from SO answer http://stackoverflow.com/questions/5125096/for-loop-in-mysql
  2. DROP DATABASE IF EXISTS hello_world;
  3. CREATE DATABASE hello_world;
  4. USE hello_world;
  5. DROP TABLE IF EXISTS World;
  6. CREATE TABLE World (
  7. id int(10) unsigned NOT NULL auto_increment,
  8. randomNumber int NOT NULL default 0,
  9. PRIMARY KEY (id)
  10. )
  11. ENGINE=INNODB;
  12. GRANT ALL ON hello_world.world TO 'benchmarkdbuser'@'%' IDENTIFIED BY 'benchmarkdbpass';
  13. GRANT ALL ON hello_world.world TO 'benchmarkdbuser'@'localhost' IDENTIFIED BY 'benchmarkdbpass';
  14. DROP PROCEDURE IF EXISTS load_data;
  15. DELIMITER #
  16. CREATE PROCEDURE load_data()
  17. BEGIN
  18. declare v_max int unsigned default 10000;
  19. declare v_counter int unsigned default 0;
  20. TRUNCATE TABLE World;
  21. START TRANSACTION;
  22. while v_counter < v_max do
  23. INSERT INTO World (randomNumber) VALUES ( floor(0 + (rand() * 10000)) );
  24. SET v_counter=v_counter+1;
  25. end while;
  26. commit;
  27. END #
  28. DELIMITER ;
  29. CALL load_data();
  30. DROP TABLE IF EXISTS Fortune;
  31. CREATE TABLE Fortune (
  32. id int(10) unsigned NOT NULL auto_increment,
  33. message varchar(2048) CHARACTER SET 'utf8' NOT NULL,
  34. PRIMARY KEY (id)
  35. )
  36. ENGINE=INNODB;
  37. INSERT INTO Fortune (message) VALUES ('fortune: No such file or directory');
  38. INSERT INTO Fortune (message) VALUES ('A computer scientist is someone who fixes things that aren''t broken.');
  39. INSERT INTO Fortune (message) VALUES ('After enough decimal places, nobody gives a damn.');
  40. INSERT INTO Fortune (message) VALUES ('A bad random number generator: 1, 1, 1, 1, 1, 4.33e+67, 1, 1, 1');
  41. INSERT INTO Fortune (message) VALUES ('A computer program does what you tell it to do, not what you want it to do.');
  42. INSERT INTO Fortune (message) VALUES ('Emacs is a nice operating system, but I prefer UNIX. — Tom Christaensen');
  43. INSERT INTO Fortune (message) VALUES ('Any program that runs right is obsolete.');
  44. INSERT INTO Fortune (message) VALUES ('A list is only as strong as its weakest link. — Donald Knuth');
  45. INSERT INTO Fortune (message) VALUES ('Feature: A bug with seniority.');
  46. INSERT INTO Fortune (message) VALUES ('Computers make very fast, very accurate mistakes.');
  47. INSERT INTO Fortune (message) VALUES ('<script>alert("This should not be displayed in a browser alert box.");</script>');
  48. INSERT INTO Fortune (message) VALUES ('フレームワークのベンチマーク');
  49. DROP TABLE IF EXISTS world;
  50. CREATE TABLE world (
  51. id int(10) unsigned NOT NULL auto_increment,
  52. randomNumber int NOT NULL default 0,
  53. PRIMARY KEY (id)
  54. )
  55. ENGINE=INNODB;
  56. DROP PROCEDURE IF EXISTS load_data;
  57. DELIMITER #
  58. CREATE PROCEDURE load_data()
  59. BEGIN
  60. declare v_max int unsigned default 10000;
  61. declare v_counter int unsigned default 0;
  62. TRUNCATE TABLE world;
  63. START TRANSACTION;
  64. while v_counter < v_max do
  65. INSERT INTO world (randomNumber) VALUES ( floor(0 + (rand() * 10000)) );
  66. SET v_counter=v_counter+1;
  67. end while;
  68. commit;
  69. END #
  70. DELIMITER ;
  71. CALL load_data();
  72. DROP TABLE IF EXISTS fortune;
  73. CREATE TABLE fortune (
  74. id int(10) unsigned NOT NULL auto_increment,
  75. message varchar(2048) CHARACTER SET 'utf8' NOT NULL,
  76. PRIMARY KEY (id)
  77. )
  78. ENGINE=INNODB;
  79. GRANT SELECT ON hello_world.fortune TO 'benchmarkdbuser'@'%' IDENTIFIED BY 'benchmarkdbpass';
  80. GRANT SELECT ON hello_world.fortune TO 'benchmarkdbuser'@'localhost' IDENTIFIED BY 'benchmarkdbpass';
  81. INSERT INTO fortune (message) VALUES ('fortune: No such file or directory');
  82. INSERT INTO fortune (message) VALUES ('A computer scientist is someone who fixes things that aren''t broken.');
  83. INSERT INTO fortune (message) VALUES ('After enough decimal places, nobody gives a damn.');
  84. INSERT INTO fortune (message) VALUES ('A bad random number generator: 1, 1, 1, 1, 1, 4.33e+67, 1, 1, 1');
  85. INSERT INTO fortune (message) VALUES ('A computer program does what you tell it to do, not what you want it to do.');
  86. INSERT INTO fortune (message) VALUES ('Emacs is a nice operating system, but I prefer UNIX. — Tom Christaensen');
  87. INSERT INTO fortune (message) VALUES ('Any program that runs right is obsolete.');
  88. INSERT INTO fortune (message) VALUES ('A list is only as strong as its weakest link. — Donald Knuth');
  89. INSERT INTO fortune (message) VALUES ('Feature: A bug with seniority.');
  90. INSERT INTO fortune (message) VALUES ('Computers make very fast, very accurate mistakes.');
  91. INSERT INTO fortune (message) VALUES ('<script>alert("This should not be displayed in a browser alert box.");</script>');
  92. INSERT INTO fortune (message) VALUES ('フレームワークのベンチマーク');