sybase.sql 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. use monotest
  2. go
  3. -- =================================== OBJECT EMPLOYEE ============================
  4. -- TABLE : INT_FAMILY
  5. -- data with id > 6000 is not gaurenteed to be read-only.
  6. if exists (select name from sysobjects where
  7. name = 'numeric_family' and type = 'U')
  8. drop table numeric_family
  9. go
  10. create table numeric_family (
  11. id int PRIMARY KEY NOT NULL,
  12. type_bit bit NOT NULL,
  13. type_tinyint tinyint NULL,
  14. type_smallint smallint NULL,
  15. type_int int NULL,
  16. type_bigint numeric (38,0) NULL,
  17. type_decimal decimal (38, 0) NULL,
  18. type_numeric numeric (38, 0) NULL,
  19. type_money money NULL,
  20. type_smallmoney smallmoney NULL)
  21. grant all on numeric_family to monotester
  22. go
  23. insert into numeric_family values (1,1,255,32767,2147483647,9223372036854775807,1000,1000,922337203685477.5807,214748.3647)
  24. insert into numeric_family values (2,0,0,-32768,-2147483648,-9223372036854775808,-1000,-1000,-922337203685477.5808,-214748.3648)
  25. insert into numeric_family values (3,0,0,0,0,0,0,0,0,0)
  26. insert into numeric_family values (4,0,null,null,null,null,null,null,null,null)
  27. go
  28. -- =================================== END OBJECT EMPLOYEE ========================
  29. -- =================================== OBJECT BINARY_FAMILY =========================
  30. -- TABLE : BINARY FAMILY
  31. -- data with id > 6000 is not gaurenteed to be read-only.
  32. if exists (select name from sysobjects where
  33. name = 'binary_family' and type = 'U')
  34. drop table binary_family
  35. go
  36. create table binary_family (
  37. id int PRIMARY KEY NOT NULL,
  38. type_binary binary (8) NULL,
  39. type_varbinary varbinary (255) NULL,
  40. type_blob image NULL,
  41. type_tinyblob image NULL,
  42. type_mediumblob image NULL,
  43. type_longblob_image image NULL)
  44. grant all on binary_family to monotester
  45. go
  46. insert into binary_family (id, type_binary, type_varbinary, type_blob, type_tinyblob, type_mediumblob, type_longblob_image) values (
  47. 1,
  48. convert (binary, '5'),
  49. convert (varbinary, '0123456789012345678901234567890123456789012345678901234567890123456789'),
  50. convert (image, '66666666'),
  51. convert (image, '777777'),
  52. convert (image, '888888'),
  53. convert (image, '999999')
  54. );
  55. insert into binary_family (id, type_binary, type_varbinary, type_blob, type_tinyblob, type_mediumblob, type_longblob_image) values (
  56. 2,
  57. convert (binary, '03423051'),
  58. convert (varbinary, '98765432101234'),
  59. convert (image, '06666666'),
  60. convert (image, '077077'),
  61. convert (image, '088088'),
  62. convert (image, '099099')
  63. );
  64. insert into binary_family (id, type_binary, type_varbinary, type_blob, type_tinyblob, type_mediumblob, type_longblob_image) values (
  65. 3,
  66. convert (binary, ''),
  67. convert (varbinary, ''),
  68. convert (image, ''),
  69. convert (image, ''),
  70. convert (image, ''),
  71. convert (image, '')
  72. );
  73. insert into binary_family (id, type_binary, type_varbinary, type_blob, type_tinyblob, type_mediumblob, type_longblob_image) values (
  74. 4,null,null,null,null,null,null);
  75. go
  76. -- =================================== END OBJECT BINARY_FAMILY ========================
  77. -- =================================== OBJECT EMPLOYEE ============================
  78. -- TABLE : EMPLOYEE
  79. -- data with id above 6000 is not gaurenteed to be read-only.
  80. if exists (select name from sysobjects where
  81. name = 'employee' and type = 'U')
  82. drop table employee
  83. go
  84. create table employee (
  85. id int PRIMARY KEY NOT NULL,
  86. fname varchar (50) NOT NULL,
  87. lname varchar (50) NULL,
  88. dob datetime NOT NULL,
  89. doj datetime NOT NULL,
  90. email varchar (50) NULL)
  91. go
  92. grant all privileges on employee to monotester
  93. insert into employee values (1, 'suresh', 'kumar', '1978-08-22', '2001-03-12', '[email protected]')
  94. insert into employee values (2, 'ramesh', 'rajendran', '1977-02-15', '2005-02-11', '[email protected]')
  95. insert into employee values (3, 'venkat', 'ramakrishnan', '1977-06-12', '2003-12-11', '[email protected]')
  96. insert into employee values (4, 'ramu', 'dhasarath', '1977-02-15', '2005-02-11', '[email protected]')
  97. go
  98. -- STORED PROCEDURES
  99. -- SP : sp_clean_employee_table
  100. if exists (select name from sysobjects where
  101. name = 'sp_clean_employee_table' and type = 'P')
  102. drop procedure sp_clean_employee_table
  103. go
  104. create procedure sp_clean_employee_table
  105. as
  106. begin
  107. delete from employee where id > 6000
  108. end
  109. go
  110. grant all on sp_clean_employee_table to monotester
  111. go
  112. -- SP : sp_get_age
  113. if exists (select name from sysobjects where
  114. name = 'sp_get_age' and type = 'P')
  115. drop procedure sp_get_age
  116. go
  117. create procedure sp_get_age (
  118. @fname varchar (50),
  119. @age int output)
  120. as
  121. begin
  122. select @age = datediff (day, dob, getdate ()) from employee where fname like @fname
  123. return @age
  124. end
  125. go
  126. grant all on sp_get_age to monotester
  127. go
  128. -- =================================== END OBJECT EMPLOYEE ============================