mysql.sql 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. delimiter //
  2. use monotest
  3. //
  4. -- =================================== OBJECT NUMERIC_FAMILY =========================
  5. -- TABLE : NUMERIC_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); insert into numeric_family values (4,null,null,null,null,null,null,null,null,null); //
  25. -- =================================== END OBJECT NUMERIC_FAMILY ========================
  26. -- =================================== OBJECT BINARY_FAMILY =========================
  27. -- TABLE : BINARY_FAMILY
  28. -- data with id > 6000 is not gaurenteed to be read-only.
  29. drop table if exists binary_family;
  30. //
  31. create table binary_family (
  32. id int PRIMARY KEY NOT NULL,
  33. type_binary binary NULL,
  34. type_varbinary varbinary (255) NULL,
  35. type_blob blob NULL,
  36. type_tinyblob tinyblob NULL,
  37. type_mediumblob mediumblob NULL,
  38. type_longblob_image longblob NULL);
  39. //
  40. insert into binary_family values (1, '555555', '0123456789012345678901234567890123456789012345678901234567890123456789', '66666666', '777777', '888888', '999999');
  41. --insert into binary_family values (2,
  42. --insert into binary_family values (3,
  43. insert into binary_family values (4,null,null,null,null,null,null);
  44. //
  45. -- =================================== END OBJECT BINARY_FAMILY ========================
  46. -- =================================== OBJECT EMPLOYEE ============================
  47. -- TABLE : EMPLOYEE
  48. -- data with id above 6000 is not gaurenteed to be read-only.
  49. drop table if exists employee;
  50. //
  51. create table employee (
  52. id int PRIMARY KEY NOT NULL,
  53. fname varchar (50) NOT NULL,
  54. lname varchar (50),
  55. dob datetime NOT NULL,
  56. doj datetime NOT NULL,
  57. email varchar (50));
  58. grant all privileges on employee to monotester;
  59. insert into employee values (1, 'suresh', 'kumar', '1978-08-22', '2001-03-12', '[email protected]');
  60. insert into employee values (2, 'ramesh', 'rajendran', '1977-02-15', '2005-02-11', '[email protected]');
  61. insert into employee values (3, 'venkat', 'ramakrishnan', '1977-06-12', '2003-12-11', '[email protected]');
  62. insert into employee values (4, 'ramu', 'dhasarath', '1977-02-15', '2005-02-11', '[email protected]');
  63. //
  64. -- STORED PROCEDURES
  65. -- SP : sp_clean_person_table
  66. drop procedure if exists sp_clean_employee_table;
  67. //
  68. create procedure sp_clean_employee_table ()
  69. begin
  70. delete from employee where id > 6000;
  71. end
  72. //
  73. -- SP : sp_get_age
  74. drop procedure if exists sp_get_age;
  75. //
  76. create procedure sp_get_age (
  77. fname varchar (50),
  78. OUT age int)
  79. as
  80. begin
  81. select age = datediff (day, dob, getdate ()) from employee where fname like fname;
  82. return age;
  83. end
  84. //
  85. -- =================================== END OBJECT EMPLOYEE ============================