create.sql 4.2 KB

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