mysql.sql 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. delimiter //
  2. use monotest
  3. //
  4. -- =================================== OBJECT NUMERIC_FAMILY =========================
  5. -- TABLE : INT_FAMILY
  6. -- data with id > 6000 is not gaurenteed to be read-only.
  7. drop table if exists numeric_family;
  8. //
  9. create table numeric_family (
  10. id int PRIMARY KEY NOT NULL,
  11. type_bit bit NULL,
  12. type_tinyint tinyint NULL,
  13. type_smallint smallint NULL,
  14. type_int int NULL,
  15. type_bigint bigint NULL,
  16. type_decimal decimal (38, 0) NULL,
  17. type_numeric numeric (38, 0) NULL,
  18. type_money numeric (38,0) NULL,
  19. type_smallmoney numeric (12,0) NULL);
  20. -- does not have money & smallmoney types
  21. //
  22. insert into numeric_family values (1,1,255,32767,2147483647,9223372036854775807,1000,1000,922337203685477.5807,214748.3647);
  23. insert into numeric_family values (2,0,0,-32768,-2147483648,-9223372036854775808,-1000,-1000,-922337203685477.5808,-214748.3648);
  24. insert into numeric_family values (3,0,0,0,0,0,0,0,0,0);
  25. insert into numeric_family values (4,null,null,null,null,null,null,null,null,null);
  26. //
  27. -- =================================== END OBJECT NUMERIC_FAMILY ========================
  28. -- =================================== OBJECT BINARY_FAMILY =========================
  29. -- TABLE : INT_FAMILY
  30. -- data with id > 6000 is not gaurenteed to be read-only.
  31. drop table if exists binary_family;
  32. //
  33. create table binary_family (
  34. id int PRIMARY KEY NOT NULL,
  35. type_binary binary NULL,
  36. type_varbinary varbinary (255) NULL,
  37. type_blob blob NULL,
  38. type_tinyblob tinyblob NULL,
  39. type_mediumblob mediumblob NULL,
  40. type_longblob_image longblob NULL);
  41. //
  42. insert into binary_family values (1, '555555', '0123456789012345678901234567890123456789012345678901234567890123456789', '66666666', '777777', '888888', '999999');
  43. --insert into binary_family values (2,
  44. --insert into binary_family values (3,
  45. insert into binary_family values (4,null,null,null,null,null,null);
  46. //
  47. -- =================================== END OBJECT BINARY_FAMILY ========================
  48. -- =================================== OBJECT EMPLOYEE ============================
  49. -- TABLE : EMPLOYEE
  50. -- data with id above 6000 is not gaurenteed to be read-only.
  51. drop table if exists employee;
  52. //
  53. create table employee (
  54. id int PRIMARY KEY NOT NULL,
  55. fname varchar (50) NOT NULL,
  56. lname varchar (50),
  57. dob datetime NOT NULL,
  58. doj datetime NOT NULL,
  59. email varchar (50));
  60. grant all privileges on employee to monotester;
  61. insert into employee values (1, 'suresh', 'kumar', '1978-08-22', '2001-03-12', '[email protected]');
  62. insert into employee values (2, 'ramesh', 'rajendran', '1977-02-15', '2005-02-11', '[email protected]');
  63. insert into employee values (3, 'venkat', 'ramakrishnan', '1977-06-12', '2003-12-11', '[email protected]');
  64. insert into employee values (4, 'ramu', 'dhasarath', '1977-02-15', '2005-02-11', '[email protected]');
  65. //
  66. -- STORED PROCEDURES
  67. -- SP : sp_clean_person_table
  68. drop procedure if exists sp_clean_employee_table;
  69. //
  70. create procedure sp_clean_employee_table ()
  71. begin
  72. delete from employee where id > 6000;
  73. end
  74. //
  75. -- SP : sp_get_age
  76. drop procedure if exists sp_get_age;
  77. //
  78. create procedure sp_get_age (
  79. fname varchar (50),
  80. OUT age int)
  81. as
  82. begin
  83. select age = datediff (day, dob, getdate ()) from employee where fname like fname;
  84. return age;
  85. end
  86. //
  87. -- =================================== END OBJECT EMPLOYEE ============================