sybase.sql 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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 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 values (1, convert (binary, '555555'), convert (varbinary, '0123456789012345678901234567890123456789012345678901234567890123456789'),
  47. convert (image, '66666666'), convert (image, '777777'),
  48. convert (image, '888888'), convert (image, '999999'))
  49. --insert into binary_family values (2,
  50. --insert into binary_family values (3,
  51. insert into binary_family values (4,null,null,null,null,null,null)
  52. go
  53. -- =================================== END OBJECT BINARY_FAMILY ========================
  54. -- =================================== OBJECT EMPLOYEE ============================
  55. -- TABLE : EMPLOYEE
  56. -- data with id above 6000 is not gaurenteed to be read-only.
  57. if exists (select name from sysobjects where
  58. name = 'employee' and type = 'U')
  59. drop table employee
  60. go
  61. create table employee (
  62. id int PRIMARY KEY NOT NULL,
  63. fname varchar (50) NOT NULL,
  64. lname varchar (50) NULL,
  65. dob datetime NOT NULL,
  66. doj datetime NOT NULL,
  67. email varchar (50) NULL)
  68. go
  69. grant all privileges on employee to monotester
  70. insert into employee values (1, 'suresh', 'kumar', '1978-08-22', '2001-03-12', '[email protected]')
  71. insert into employee values (2, 'ramesh', 'rajendran', '1977-02-15', '2005-02-11', '[email protected]')
  72. insert into employee values (3, 'venkat', 'ramakrishnan', '1977-06-12', '2003-12-11', '[email protected]')
  73. insert into employee values (4, 'ramu', 'dhasarath', '1977-02-15', '2005-02-11', '[email protected]')
  74. go
  75. -- STORED PROCEDURES
  76. -- SP : sp_clean_employee_table
  77. if exists (select name from sysobjects where
  78. name = 'sp_clean_employee_table' and type = 'P')
  79. drop procedure sp_clean_employee_table
  80. go
  81. create procedure sp_clean_employee_table
  82. as
  83. begin
  84. delete from employee where id > 6000
  85. end
  86. go
  87. grant all on sp_clean_employee_table to monotester
  88. go
  89. -- SP : sp_get_age
  90. if exists (select name from sysobjects where
  91. name = 'sp_get_age' and type = 'P')
  92. drop procedure sp_get_age
  93. go
  94. create procedure sp_get_age (
  95. @fname varchar (50),
  96. @age int output)
  97. as
  98. begin
  99. select @age = datediff (day, dob, getdate ()) from employee where fname like @fname
  100. return @age
  101. end
  102. go
  103. grant all on sp_get_age to monotester
  104. go
  105. -- =================================== END OBJECT EMPLOYEE ============================