Welcome to mirror list, hosted at ThFree Co, Russian Federation.

MySQL_5.sql « sql « ProviderTests « Test « System.Data « class « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 540066b78bf6815985498f839e5733f292986a7a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
/*
=========================================================================================
MySQL_5.sql
Author: Amit Biswas (amit@amitbiswas.com)

This sql script performs the same operations as "mysql.sql" but some sql commands
have been changed either to fix bugs or to comply with MySQL Server 5.0
15-Dec-2007

Changes:
--------
In numeric_family, the column type_tinyint cannot store the value 255, hence changed it to 127
Reason: tinyint takes 1 byte and stores from -128 to 127 (http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html)
(ERROR: Out of range value adjusted for column 'type_tinyint')

In numeric_family, the column type_double was declared as float NULL which cannot store the value 1.79E+308, hence it changed it to float (53)
Reason: MySQL supports the optional precision specification but the precision value is used only
to determine storage size. A precision from 0 to 23 results in a four-byte single-precision FLOAT column.
A precision from 24 to 53 results in an eight-byte double-precision DOUBLE column.
(http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html)

In binary_family, the column type_binary was declared as binary NULL which cannot store the value 555555, hence changed it to binary (8)
Reason: In case of binary (and varbinary) fields the length indicates bytes, not characters. (http://dev.mysql.com/doc/refman/5.0/en/binary-varbinary.html)
(ERROR: Data too long for column 'type_binary')

In datetime_family, the column type_smalldatetime was declared as timestamp NULL which cannot store the year 2079, hence changed it to 2037-12-31 23:59:00
Reason: The range of timestamp is '1970-01-01 00:00:01' to 2037, (http://dev.mysql.com/doc/refman/5.0/en/date-and-time-type-overview.html)
(ERROR: Incorrect datetime value: '2079-06-06 23:59:00' for column 'type_smalldatetime')

Stored Procedures:
------------------
Modified the "Create Procedure" statement
Reason: the existing statement doesnt work in MySQL Administrator, MySQL 5.0.27

Removed the "Return" statement in the stored procedure sp_get_age
Reason: "Return" is only allowed in a function not in a procedure, u can use "INTO" instead

===========================================================================================
*/




use monotest;

/*
=================================== OBJECT NUMERIC_FAMILY =========================
-- TABLE : NUMERIC_FAMILY
-- data with id > 6000 is not gaurenteed to be read-only.
*/

drop table if exists numeric_family;


create table `numeric_family` (
	`id` int PRIMARY KEY NOT NULL,
	`type_bit` bit NULL,
	`type_tinyint` tinyint NULL,
	`type_smallint` smallint NULL,
	`type_int` int NULL,
	`type_bigint` bigint NULL,
	`type_decimal` decimal (38, 0) NULL,
	`type_numeric` numeric (38, 0) NULL,
	`type_money` numeric (38,0) NULL,
	`type_smallmoney` numeric (12,0) NULL,
  `type_float` real NULL,
  `type_double` float (53));

insert into `numeric_family` values (1,1,127,32767,2147483647,9223372036854775807,1000,1000,922337203685477.5807,214748.3647,3.40E+38,1.79E+308);
insert into `numeric_family` values (2,0,0,-32768,-2147483648,-9223372036854775808,-1000,-1000,-922337203685477.5808,-214748.3648,-3.40E+38,-1.79E+308);
insert into `numeric_family` values (3,0,0,0,0,0,0,0,0,0,0,0);
insert into `numeric_family` values (4,null,null,null,null,null,null,null,null,null,null,null);

/*
-- =================================== END OBJECT NUMERIC_FAMILY ========================


-- =================================== OBJECT BINARY_FAMILY =========================
-- TABLE : BINARY_FAMILY
-- data with id > 6000 is not gaurenteed to be read-only.
*/

drop table if exists binary_family;

create table `binary_family` (
	`id` int PRIMARY KEY NOT NULL,
	`type_binary` binary (8),
	`type_varbinary` varbinary (255) NULL,
	`type_blob` blob NULL,
	`type_tinyblob` tinyblob NULL,
	`type_mediumblob` mediumblob NULL,
	`type_longblob_image` longblob NULL);

insert into `binary_family` values (1, '555555', '0123456789012345678901234567890123456789012345678901234567890123456789', '66666666', '777777', '888888', '999999');
/* --insert into binary_family values (2,
--insert into binary_family values (3,
*/
insert into `binary_family` values (4,null,null,null,null,null,null);

/*
-- =================================== END OBJECT BINARY_FAMILY ========================


-- =================================== OBJECT STRING_FAMILY============================
-- TABLE : string_family 
-- data with id above 6000 is not gaurenteed to be read-only.
*/

drop table if exists string_family;

create table `string_family` (
	`id` int PRIMARY KEY NOT NULL,
      `type_char` char(10) NULL,
      `type_varchar` varchar(10) NULL,
      `type_text` text NULL,
      `type_ntext` longtext NULL);

grant all privileges on string_family to monotester;

insert into `string_family` values (1,"char","varchar","text","ntext");
insert into `string_family` values (2, '0123456789','varchar' ,'longtext longtext longtext longtext longtext longtext longtext longtext longtext longtext longtext longtext longtext longtext longtext longtext longtext longtext longtext longtext longtext longtext longtext longtext longtext longtext longtext longtext longtext longtext ','ntext');
insert into `string_family` values (4,null,null,null,null);

/*
-- =================================== END OBJECT STRING_FAMILY ========================


-- =================================== OBJECT DATETIME_FAMILY============================
-- TABLE : datetime_family
-- data with id above 6000 is not gaurenteed to be read-only.
*/

drop table if exists datetime_family;

create table `datetime_family` (
        `id` int PRIMARY KEY NOT NULL,
        `type_smalldatetime` timestamp NULL,
        `type_datetime` datetime NULL);

grant all privileges on datetime_family to monotester;

insert into `datetime_family` values (1,'2037-12-31 23:59:00','9999-12-31 23:59:59.997');
insert into `datetime_family` values (4,null,null);

/*
-- =================================== END OBJECT DATETIME_FAMILY========================


-- =================================== OBJECT EMPLOYEE ============================
-- TABLE : EMPLOYEE
-- data with id above 6000 is not gaurenteed to be read-only.
*/

drop table if exists employee;

create table `employee` (
	`id` int PRIMARY KEY NOT NULL,
	`fname` varchar (50) NOT NULL,
	`lname` varchar (50),
	`dob` datetime NOT NULL,
	`doj` datetime NOT NULL,
	`email` varchar (50));

grant all privileges on employee to monotester;

insert into `employee` values (1, 'suresh', 'kumar', '1978-08-22', '2001-03-12', 'suresh@gmail.com');
insert into `employee` values (2, 'ramesh', 'rajendran', '1977-02-15', '2005-02-11', 'ramesh@yahoo.com');
insert into `employee` values (3, 'venkat', 'ramakrishnan', '1977-06-12', '2003-12-11', 'ramesh@yahoo.com');
insert into `employee` values (4, 'ramu', 'dhasarath', '1977-02-15', '2005-02-11', 'ramesh@yahoo.com');

/*
-- STORED PROCEDURES
-- SP : sp_clean_person_table
*/

delimiter //
drop procedure if exists sp_clean_employee_table
//
CREATE DEFINER=`monotester`@`localhost` PROCEDURE `sp_clean_employee_table`()
begin
	delete from employee where `id` > 6000;
end
//

/*
-- SP : sp_get_age
*/

drop procedure if exists sp_get_age
//
create procedure sp_get_age (fname varchar (50), OUT age int)
begin
	select age = datediff (day, dob, getdate ()) from employee where fname like fname;
  /* you can also use SELECT ..... INTO age */
end
//
/*
-- =================================== END OBJECT EMPLOYEE ============================
*/

/*
=========================================================================================
MySQL_5.sql
Author: Amit Biswas (amit@amitbiswas.com)

This sql script performs the same operations as "mysql.sql" but some sql commands
have been changed either to fix bugs or to comply with MySQL Server 5.0
15-Dec-2007

Changes:
--------
In numeric_family, the column type_tinyint cannot store the value 255, hence changed it to 127
Reason: tinyint takes 1 byte and stores from -128 to 127 (http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html)
(ERROR: Out of range value adjusted for column 'type_tinyint')

In numeric_family, the column type_double was declared as float NULL which cannot store the value 1.79E+308, hence it changed it to float (53)
Reason: MySQL supports the optional precision specification but the precision value is used only
to determine storage size. A precision from 0 to 23 results in a four-byte single-precision FLOAT column.
A precision from 24 to 53 results in an eight-byte double-precision DOUBLE column.
(http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html)

In binary_family, the column type_binary was declared as binary NULL which cannot store the value 555555, hence changed it to binary (8)
Reason: In case of binary (and varbinary) fields the length indicates bytes, not characters. (http://dev.mysql.com/doc/refman/5.0/en/binary-varbinary.html)
(ERROR: Data too long for column 'type_binary')

In datetime_family, the column type_smalldatetime was declared as timestamp NULL which cannot store the year 2079, hence changed it to 2037-12-31 23:59:00
Reason: The range of timestamp is '1970-01-01 00:00:01' to 2037, (http://dev.mysql.com/doc/refman/5.0/en/date-and-time-type-overview.html)
(ERROR: Incorrect datetime value: '2079-06-06 23:59:00' for column 'type_smalldatetime')

Stored Procedures:
------------------
Modified the "Create Procedure" statement
Reason: the existing statement doesnt work in MySQL Administrator, MySQL 5.0.27

Removed the "Return" statement in the stored procedure sp_get_age
Reason: "Return" is only allowed in a function not in a procedure, u can use "INTO" instead

===========================================================================================
*/

use monotest;

/*
=================================== OBJECT NUMERIC_FAMILY =========================
-- TABLE : NUMERIC_FAMILY
-- data with id > 6000 is not gaurenteed to be read-only.
*/

drop table if exists numeric_family;


create table `numeric_family` (
	`id` int PRIMARY KEY NOT NULL,
	`type_bit` bit NULL,
	`type_tinyint` tinyint NULL,
	`type_smallint` smallint NULL,
	`type_int` int NULL,
	`type_bigint` bigint NULL,
	`type_decimal` decimal (38, 0) NULL,
	`type_numeric` numeric (38, 0) NULL,
	`type_money` numeric (38,0) NULL,
	`type_smallmoney` numeric (12,0) NULL,
  `type_float` real NULL,
  `type_double` float (53));

insert into `numeric_family` values (1,1,127,32767,2147483647,9223372036854775807,1000,1000,922337203685477.5807,214748.3647,3.40E+38,1.79E+308);
insert into `numeric_family` values (2,0,0,-32768,-2147483648,-9223372036854775808,-1000,-1000,-922337203685477.5808,-214748.3648,-3.40E+38,-1.79E+308);
insert into `numeric_family` values (3,0,0,0,0,0,0,0,0,0,0,0);
insert into `numeric_family` values (4,null,null,null,null,null,null,null,null,null,null,null);

/*
-- =================================== END OBJECT NUMERIC_FAMILY ========================


-- =================================== OBJECT BINARY_FAMILY =========================
-- TABLE : BINARY_FAMILY
-- data with id > 6000 is not gaurenteed to be read-only.
*/

drop table if exists binary_family;

create table `binary_family` (
	`id` int PRIMARY KEY NOT NULL,
	`type_binary` binary (8),
	`type_varbinary` varbinary (255) NULL,
	`type_blob` blob NULL,
	`type_tinyblob` tinyblob NULL,
	`type_mediumblob` mediumblob NULL,
	`type_longblob_image` longblob NULL);

insert into `binary_family` values (1, '555555', '0123456789012345678901234567890123456789012345678901234567890123456789', '66666666', '777777', '888888', '999999');
/* --insert into binary_family values (2,
--insert into binary_family values (3,
*/
insert into `binary_family` values (4,null,null,null,null,null,null);

/*
-- =================================== END OBJECT BINARY_FAMILY ========================


-- =================================== OBJECT STRING_FAMILY============================
-- TABLE : string_family 
-- data with id above 6000 is not gaurenteed to be read-only.
*/

drop table if exists string_family;

create table `string_family` (
	`id` int PRIMARY KEY NOT NULL,
      `type_char` char(10) NULL,
      `type_varchar` varchar(10) NULL,
      `type_text` text NULL,
      `type_ntext` longtext NULL);

grant all privileges on string_family to monotester;

insert into `string_family` values (1,"char","varchar","text","ntext");
insert into `string_family` values (2, '0123456789','varchar' ,'longtext longtext longtext longtext longtext longtext longtext longtext longtext longtext longtext longtext longtext longtext longtext longtext longtext longtext longtext longtext longtext longtext longtext longtext longtext longtext longtext longtext longtext longtext ','ntext');
insert into `string_family` values (4,null,null,null,null);

/*
-- =================================== END OBJECT STRING_FAMILY ========================


-- =================================== OBJECT DATETIME_FAMILY============================
-- TABLE : datetime_family
-- data with id above 6000 is not gaurenteed to be read-only.
*/

drop table if exists datetime_family;

create table `datetime_family` (
        `id` int PRIMARY KEY NOT NULL,
        `type_smalldatetime` timestamp NULL,
        `type_datetime` datetime NULL);

grant all privileges on datetime_family to monotester;

insert into `datetime_family` values (1,'2037-12-31 23:59:00','9999-12-31 23:59:59.997');
insert into `datetime_family` values (4,null,null);

/*
-- =================================== END OBJECT DATETIME_FAMILY========================


-- =================================== OBJECT EMPLOYEE ============================
-- TABLE : EMPLOYEE
-- data with id above 6000 is not gaurenteed to be read-only.
*/

drop table if exists employee;

create table `employee` (
	`id` int PRIMARY KEY NOT NULL,
	`fname` varchar (50) NOT NULL,
	`lname` varchar (50),
	`dob` datetime NOT NULL,
	`doj` datetime NOT NULL,
	`email` varchar (50));

grant all privileges on employee to monotester;

insert into `employee` values (1, 'suresh', 'kumar', '1978-08-22', '2001-03-12', 'suresh@gmail.com');
insert into `employee` values (2, 'ramesh', 'rajendran', '1977-02-15', '2005-02-11', 'ramesh@yahoo.com');
insert into `employee` values (3, 'venkat', 'ramakrishnan', '1977-06-12', '2003-12-11', 'ramesh@yahoo.com');
insert into `employee` values (4, 'ramu', 'dhasarath', '1977-02-15', '2005-02-11', 'ramesh@yahoo.com');

/*
-- STORED PROCEDURES
-- SP : sp_clean_person_table
*/

delimiter //
drop procedure if exists sp_clean_employee_table
//
CREATE DEFINER=`monotester`@`localhost` PROCEDURE `sp_clean_employee_table`()
begin
	delete from employee where `id` > 6000;
end
//

/*
-- SP : sp_get_age
*/

drop procedure if exists sp_get_age
//
create procedure sp_get_age (fname varchar (50), OUT age int)
begin
	select age = datediff (day, dob, getdate ()) from employee where fname like fname;
  /* you can also use SELECT ..... INTO age */
end
//
/*
-- =================================== END OBJECT EMPLOYEE ============================
*/