~drizzle-trunk/drizzle/development

1 by brian
clean slate
1
drop table if exists t1,t2,t3;
2
drop database if exists mysqltest;
3
create table t1(id1 int not null auto_increment primary key, t char(12));
4
create table t2(id2 int not null, t char(12));
5
create table t3(id3 int not null, t char(12), index(id3));
6
select count(*) from t1 where id1 > 95;
7
count(*)
8
5
9
select count(*) from t2 where id2 > 95;
10
count(*)
11
25
12
select count(*) from t3 where id3 > 95;
13
count(*)
14
250
15
update t1,t2,t3 set t1.t="aaa", t2.t="bbb", t3.t="cc" where  t1.id1 = t2.id2 and t2.id2 = t3.id3  and t1.id1 > 90;
16
select count(*) from t1 where t = "aaa";
17
count(*)
18
10
19
select count(*) from t1 where id1 > 90;
20
count(*)
21
10
22
select count(*) from t2 where t = "bbb";
23
count(*)
24
50
25
select count(*) from t2 where id2 > 90;
26
count(*)
27
50
28
select count(*) from t3 where t = "cc";
29
count(*)
30
500
31
select count(*) from t3 where id3 > 90;
32
count(*)
33
500
34
delete t1.*, t2.*, t3.*  from t1,t2,t3 where t1.id1 = t2.id2 and t2.id2 = t3.id3  and t1.id1 > 95;
35
check table t1, t2, t3;
36
Table	Op	Msg_type	Msg_text
37
test.t1	check	status	OK
38
test.t2	check	status	OK
39
test.t3	check	status	OK
40
select count(*) from t1 where id1 > 95;
41
count(*)
42
0
43
select count(*) from t2 where id2 > 95;
44
count(*)
45
0
46
select count(*) from t3 where id3 > 95;
47
count(*)
48
0
49
delete t1, t2, t3  from t1,t2,t3 where t1.id1 = t2.id2 and t2.id2 = t3.id3  and t1.id1 > 5;
50
select count(*) from t1 where id1 > 5;
51
count(*)
52
0
53
select count(*) from t2 where id2 > 5;
54
count(*)
55
0
56
select count(*) from t3 where id3 > 5;
57
count(*)
58
0
59
delete from t1, t2, t3  using t1,t2,t3 where t1.id1 = t2.id2 and t2.id2 = t3.id3  and t1.id1 > 0;
60
select count(*) from t1 where id1;
61
count(*)
62
0
63
select count(*) from t2 where id2;
64
count(*)
65
0
66
select count(*) from t3 where id3;
67
count(*)
68
0
69
drop table t1,t2,t3;
70
create table t1(id1 int not null  primary key, t varchar(100)) pack_keys = 1;
71
create table t2(id2 int not null, t varchar(100), index(id2)) pack_keys = 1;
72
delete t1  from t1,t2 where t1.id1 = t2.id2 and t1.id1 > 500;
73
drop table t1,t2;
74
CREATE TABLE t1 (
685.4.9 by Jay Pipes
multi_update.test now working. Removed VIEWs and other stuff, validated result
75
id int NOT NULL default '0',
1 by brian
clean slate
76
name varchar(10) default NULL,
77
PRIMARY KEY  (id)
78
) ENGINE=MyISAM;
79
INSERT INTO t1 VALUES (1,'aaa'),(2,'aaa'),(3,'aaa');
80
CREATE TABLE t2 (
685.4.9 by Jay Pipes
multi_update.test now working. Removed VIEWs and other stuff, validated result
81
id int NOT NULL default '0',
1 by brian
clean slate
82
name varchar(10) default NULL,
83
PRIMARY KEY  (id)
84
) ENGINE=MyISAM;
85
INSERT INTO t2 VALUES (2,'bbb'),(3,'bbb'),(4,'bbb');
86
CREATE TABLE t3 (
685.4.9 by Jay Pipes
multi_update.test now working. Removed VIEWs and other stuff, validated result
87
id int NOT NULL default '0',
1 by brian
clean slate
88
mydate datetime default NULL,
89
PRIMARY KEY  (id)
90
) ENGINE=MyISAM;
91
INSERT INTO t3 VALUES (1,'2002-02-04 00:00:00'),(3,'2002-05-12 00:00:00'),(5,'2002-05-12 00:00:00'),(6,'2002-06-22
92
00:00:00'),(7,'2002-07-22 00:00:00');
93
delete t1,t2,t3 from t1,t2,t3 where to_days(now())-to_days(t3.mydate)>=30 and t3.id=t1.id and t3.id=t2.id;
94
select * from t3;
95
id	mydate
96
1	2002-02-04 00:00:00
97
5	2002-05-12 00:00:00
98
6	2002-06-22 00:00:00
99
7	2002-07-22 00:00:00
100
DROP TABLE t1,t2,t3;
101
CREATE TABLE IF NOT EXISTS `t1` (
685.4.9 by Jay Pipes
multi_update.test now working. Removed VIEWs and other stuff, validated result
102
`id` int NOT NULL auto_increment,
1 by brian
clean slate
103
`tst` text,
104
`tst1` text,
105
PRIMARY KEY  (`id`)
106
) ENGINE=MyISAM;
107
CREATE TABLE IF NOT EXISTS `t2` (
685.4.9 by Jay Pipes
multi_update.test now working. Removed VIEWs and other stuff, validated result
108
`ID` int NOT NULL auto_increment,
109
`ParId` int default NULL,
1 by brian
clean slate
110
`tst` text,
111
`tst1` text,
112
PRIMARY KEY  (`ID`),
113
KEY `IX_ParId_t2` (`ParId`),
114
FOREIGN KEY (`ParId`) REFERENCES `t1` (`id`)
115
) ENGINE=MyISAM;
116
INSERT INTO t1(tst,tst1) VALUES("MySQL","MySQL AB"), ("MSSQL","Microsoft"), ("ORACLE","ORACLE");
117
INSERT INTO t2(ParId) VALUES(1), (2), (3);
118
select * from t2;
119
ID	ParId	tst	tst1
120
1	1	NULL	NULL
121
2	2	NULL	NULL
122
3	3	NULL	NULL
123
UPDATE t2, t1 SET t2.tst = t1.tst, t2.tst1 = t1.tst1 WHERE t2.ParId = t1.Id;
124
select * from t2;
125
ID	ParId	tst	tst1
126
1	1	MySQL	MySQL AB
127
2	2	MSSQL	Microsoft
128
3	3	ORACLE	ORACLE
129
drop table t1, t2 ;
130
create table t1 (n numeric(10));
131
create table t2 (n numeric(10));
132
insert into t2 values (1),(2),(4),(8),(16),(32);
133
select * from t2 left outer join t1  using (n);
134
n
135
1
136
2
137
4
138
8
139
16
140
32
141
delete  t1,t2 from t2 left outer join t1  using (n);
142
select * from t2 left outer join t1  using (n);
143
n
144
drop table t1,t2 ;
685.4.9 by Jay Pipes
multi_update.test now working. Removed VIEWs and other stuff, validated result
145
create table t1 (n int not null primary key, d int);
146
create table t2 (n int not null primary key, d int);
1 by brian
clean slate
147
insert into t1 values(1,1);
148
insert into t2 values(1,10),(2,20);
149
LOCK TABLES t1 write, t2 read;
150
DELETE t1.*, t2.* FROM t1,t2 where t1.n=t2.n;
151
ERROR HY000: Table 't2' was locked with a READ lock and can't be updated
152
UPDATE t1,t2 SET t1.d=t2.d,t2.d=30 WHERE t1.n=t2.n;
153
ERROR HY000: Table 't2' was locked with a READ lock and can't be updated
154
UPDATE t1,t2 SET t1.d=t2.d WHERE t1.n=t2.n;
155
unlock tables;
156
LOCK TABLES t1 write, t2 write;
157
UPDATE t1,t2 SET t1.d=t2.d WHERE t1.n=t2.n;
158
select * from t1;
159
n	d
160
1	10
161
DELETE t1.*, t2.* FROM t1,t2 where t1.n=t2.n;
162
select * from t1;
163
n	d
164
select * from t2;
165
n	d
166
2	20
167
unlock tables;
168
drop table t1,t2;
169
set sql_safe_updates=1;
685.4.9 by Jay Pipes
multi_update.test now working. Removed VIEWs and other stuff, validated result
170
create table t1 (n int, d int);
171
create table t2 (n int, d int);
1 by brian
clean slate
172
insert into t1 values(1,1);
173
insert into t2 values(1,10),(2,20);
174
UPDATE t1,t2 SET t1.d=t2.d WHERE t1.n=t2.n;
175
ERROR HY000: You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column
176
set sql_safe_updates=0;
177
drop table t1,t2;
178
set timestamp=1038401397;
685.4.9 by Jay Pipes
multi_update.test now working. Removed VIEWs and other stuff, validated result
179
create table t1 (n int not null primary key, d int, t timestamp);
180
create table t2 (n int not null primary key, d int, t timestamp);
1 by brian
clean slate
181
insert into t1 values(1,1,NULL);
182
insert into t2 values(1,10,NULL),(2,20,NULL);
183
set timestamp=1038000000;
184
UPDATE t1,t2 SET t1.d=t2.d WHERE t1.n=t2.n;
185
select n,d,unix_timestamp(t) from t1;
186
n	d	unix_timestamp(t)
187
1	10	1038000000
188
select n,d,unix_timestamp(t) from t2;
189
n	d	unix_timestamp(t)
190
1	10	1038401397
191
2	20	1038401397
192
UPDATE t1,t2 SET 1=2 WHERE t1.n=t2.n;
685.4.9 by Jay Pipes
multi_update.test now working. Removed VIEWs and other stuff, validated result
193
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your Drizzle server version for the right syntax to use near '1=2 WHERE t1.n=t2.n' at line 1
1 by brian
clean slate
194
drop table t1,t2;
195
set timestamp=0;
196
set sql_safe_updates=0;
685.4.9 by Jay Pipes
multi_update.test now working. Removed VIEWs and other stuff, validated result
197
create table t1 (n int not null primary key, d int);
198
create table t2 (n int not null primary key, d int);
1 by brian
clean slate
199
insert into t1 values(1,1), (3,3);
200
insert into t2 values(1,10),(2,20);
201
UPDATE t2 left outer join t1 on t1.n=t2.n  SET t1.d=t2.d;
202
select * from t1;
203
n	d
204
1	10
205
3	3
206
select * from t2;
207
n	d
208
1	10
209
2	20
210
drop table t1,t2;
685.4.9 by Jay Pipes
multi_update.test now working. Removed VIEWs and other stuff, validated result
211
create table t1 (n int, d int);
212
create table t2 (n int, d int);
1 by brian
clean slate
213
insert into t1 values(1,1),(1,2);
214
insert into t2 values(1,10),(2,20);
215
UPDATE t1,t2 SET t1.d=t2.d,t2.d=30 WHERE t1.n=t2.n;
216
select * from t1;
217
n	d
218
1	10
219
1	10
220
select * from t2;
221
n	d
222
1	30
223
2	20
224
drop table t1,t2;
685.4.9 by Jay Pipes
multi_update.test now working. Removed VIEWs and other stuff, validated result
225
create table t1 (n int, d int);
226
create table t2 (n int, d int);
1 by brian
clean slate
227
insert into t1 values(1,1),(3,2);
228
insert into t2 values(1,10),(1,20);
229
UPDATE t1,t2 SET t1.d=t2.d,t2.d=30 WHERE t1.n=t2.n;
230
select * from t1;
231
n	d
232
1	10
233
3	2
234
select * from t2;
235
n	d
236
1	30
237
1	30
238
UPDATE t1 a ,t2 b SET a.d=b.d,b.d=30 WHERE a.n=b.n;
239
select * from t1;
240
n	d
241
1	30
242
3	2
243
select * from t2;
244
n	d
245
1	30
246
1	30
247
DELETE a, b  FROM t1 a,t2 b where a.n=b.n;
248
select * from t1;
249
n	d
250
3	2
251
select * from t2;
252
n	d
253
drop table t1,t2;
685.4.9 by Jay Pipes
multi_update.test now working. Removed VIEWs and other stuff, validated result
254
CREATE TABLE t1 ( broj int NOT NULL default '0',  naziv char(25) NOT NULL default 'NEPOZNAT',  PRIMARY KEY  (broj)) ENGINE=MyISAM;
1 by brian
clean slate
255
INSERT INTO t1 VALUES (1,'jedan'),(2,'dva'),(3,'tri'),(4,'xxxxxxxxxx'),(5,'a'),(10,''),(11,''),(12,''),(13,'');
685.4.9 by Jay Pipes
multi_update.test now working. Removed VIEWs and other stuff, validated result
256
CREATE TABLE t2 ( broj int NOT NULL default '0',  naziv char(25) NOT NULL default 'NEPOZNAT',  PRIMARY KEY  (broj)) ENGINE=MyISAM;
1 by brian
clean slate
257
INSERT INTO t2 VALUES (1,'jedan'),(2,'dva'),(3,'tri'),(4,'xxxxxxxxxx'),(5,'a');
685.4.9 by Jay Pipes
multi_update.test now working. Removed VIEWs and other stuff, validated result
258
CREATE TABLE t3 ( broj int NOT NULL default '0',  naziv char(25) NOT NULL default 'NEPOZNAT',  PRIMARY KEY  (broj)) ENGINE=MyISAM;
1 by brian
clean slate
259
INSERT INTO t3 VALUES (1,'jedan'),(2,'dva');
260
update t1,t2 set t1.naziv="aaaa" where t1.broj=t2.broj;
261
update t1,t2,t3 set t1.naziv="bbbb", t2.naziv="aaaa" where t1.broj=t2.broj and t2.broj=t3.broj;
262
drop table t1,t2,t3;
263
CREATE TABLE t1 (a int not null primary key, b int not null, key (b));
264
CREATE TABLE t2 (a int not null primary key, b int not null, key (b));
265
INSERT INTO t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9);
266
INSERT INTO t2 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9);
267
update t1,t2 set t1.a=t1.a+100;
268
select * from t1;
269
a	b
270
101	1
271
102	2
272
103	3
273
104	4
274
105	5
275
106	6
276
107	7
277
108	8
278
109	9
279
update t1,t2 set t1.a=t1.a+100 where t1.a=101;
280
select * from t1;
281
a	b
282
102	2
283
103	3
284
104	4
285
105	5
286
106	6
287
107	7
288
108	8
289
109	9
685.4.9 by Jay Pipes
multi_update.test now working. Removed VIEWs and other stuff, validated result
290
201	1
1 by brian
clean slate
291
update t1,t2 set t1.b=t1.b+10 where t1.b=2;
292
select * from t1;
293
a	b
294
102	12
295
103	3
296
104	4
297
105	5
298
106	6
299
107	7
300
108	8
301
109	9
685.4.9 by Jay Pipes
multi_update.test now working. Removed VIEWs and other stuff, validated result
302
201	1
1 by brian
clean slate
303
update t1,t2 set t1.b=t1.b+2,t2.b=t1.b+10 where t1.b between 3 and 5 and t2.a=t1.a-100;
304
select * from t1;
305
a	b
306
102	12
307
103	5
308
104	6
309
105	7
310
106	6
311
107	7
312
108	8
313
109	9
685.4.9 by Jay Pipes
multi_update.test now working. Removed VIEWs and other stuff, validated result
314
201	1
1 by brian
clean slate
315
select * from t2;
316
a	b
317
1	1
318
2	2
685.4.9 by Jay Pipes
multi_update.test now working. Removed VIEWs and other stuff, validated result
319
3	15
320
4	16
321
5	17
1 by brian
clean slate
322
6	6
323
7	7
324
8	8
325
9	9
326
update t1,t2 set t1.b=t2.b, t1.a=t2.a where t1.a=t2.a and not exists (select * from t2 where t2.a > 10);
327
drop table t1,t2;
685.4.9 by Jay Pipes
multi_update.test now working. Removed VIEWs and other stuff, validated result
328
CREATE TABLE t3 (  KEY1 varchar(50) NOT NULL default '',  PARAM_CORR_DISTANCE_RUSH double default NULL,  PARAM_CORR_DISTANCE_GEM double default NULL,  PARAM_AVG_TARE double default NULL,  PARAM_AVG_NB_DAYS double default NULL,  PARAM_DEFAULT_PROP_GEM_SRVC varchar(50) default NULL,  PARAM_DEFAULT_PROP_GEM_NO_ETIK varchar(50) default NULL,  PARAM_SCENARIO_COSTS varchar(50) default NULL,  PARAM_DEFAULT_WAGON_COST double default NULL,  tmp int default NULL,  PRIMARY KEY  (KEY1)) ENGINE=MyISAM;
1 by brian
clean slate
329
INSERT INTO t3 VALUES ('A',1,1,22,3.2,'R','R','BASE2',0.24,NULL);
330
create table t1 (A varchar(1));
331
insert into t1 values  ("A") ,("B"),("C"),("D");
332
create table t2(Z varchar(15));
333
insert into t2(Z)  select concat(a.a,b.a,c.a,d.a) from t1 as a, t1 as b, t1 as c, t1 as d;
334
update t2,t3 set Z =param_scenario_costs;
335
drop table t1,t2,t3;
336
create table t1 (a int, b int);
337
create table t2 (a int, b int);
338
insert into t1 values (1,1),(2,1),(3,1);
339
insert into t2 values (1,1), (3,1);
340
update t1 left join t2  on t1.a=t2.a set t1.b=2, t2.b=2 where t1.b=1 and t2.b=1 or t2.a is NULL;
341
select t1.a, t1.b,t2.a, t2.b from t1 left join t2  on t1.a=t2.a where t1.b=1 and t2.b=1 or t2.a is NULL;
342
a	b	a	b
343
2	2	NULL	NULL
344
drop table t1,t2;
345
create table t1 (a int not null auto_increment primary key, b int not null);
346
insert into t1 (b) values (1),(2),(3),(4);
347
update t1, t1 as t2 set t1.b=t2.b+1 where t1.a=t2.a;
348
select * from t1;
349
a	b
350
1	2
351
2	3
352
3	4
353
4	5
354
drop table t1;
685.4.9 by Jay Pipes
multi_update.test now working. Removed VIEWs and other stuff, validated result
355
create table t1(id1 int, field char(5));
356
create table t2(id2 int, field char(5));
1 by brian
clean slate
357
insert into t1 values (1, 'a'), (2, 'aa');
358
insert into t2 values (1, 'b'), (2, 'bb');
359
select * from t1;
360
id1	field
361
1	a
362
2	aa
363
select * from t2;
364
id2	field
365
1	b
366
2	bb
367
update t2 inner join t1 on t1.id1=t2.id2
368
set t2.field=t1.field
369
where 0=1;
370
update t2, t1 set t2.field=t1.field
371
where t1.id1=t2.id2 and 0=1;
372
delete t1, t2 from t2 inner join t1 on t1.id1=t2.id2
373
where 0=1;
374
delete t1, t2 from t2,t1 
375
where t1.id1=t2.id2 and 0=1;
376
drop table t1,t2;
377
create table t1 ( a int not null, b int not null) ;
378
alter table t1 add index i1(a);
379
delete from t1 where a > 2000000;
380
create table t2 like t1;
381
insert into t2 select * from t1;
382
select 't2 rows before small delete', count(*) from t1;
383
t2 rows before small delete	count(*)
384
t2 rows before small delete	2000000
385
delete t1,t2 from t1,t2 where t1.b=t2.a and t1.a < 2;
386
select 't2 rows after small delete', count(*) from t2;
387
t2 rows after small delete	count(*)
388
t2 rows after small delete	1999999
389
select 't1 rows after small delete', count(*) from t1;
390
t1 rows after small delete	count(*)
391
t1 rows after small delete	1999999
392
delete t1,t2 from t1,t2 where t1.b=t2.a and t1.a < 100*1000;
393
select 't2 rows after big delete', count(*) from t2;
394
t2 rows after big delete	count(*)
395
t2 rows after big delete	1900001
396
select 't1 rows after big delete', count(*) from t1;
397
t1 rows after big delete	count(*)
398
t1 rows after big delete	1900001
399
drop table t1,t2;
400
CREATE TABLE t1 ( a int );
401
CREATE TABLE t2 ( a int );
402
DELETE t1 FROM t1, t2 AS t3;
403
DELETE t4 FROM t1, t1 AS t4;
404
DELETE t3 FROM t1 AS t3, t1 AS t4;
405
DELETE t1 FROM t1 AS t3, t2 AS t4;
406
ERROR 42S02: Unknown table 't1' in MULTI DELETE
407
INSERT INTO t1 values (1),(2);
408
INSERT INTO t2 values (1),(2);
409
DELETE t1 FROM t1 AS t2, t2 AS t1 where t1.a=t2.a and t1.a=1;
410
SELECT * from t1;
411
a
412
1
413
2
414
SELECT * from t2;
415
a
416
2
417
DELETE t2 FROM t1 AS t2, t2 AS t1 where t1.a=t2.a and t1.a=2;
418
SELECT * from t1;
419
a
420
1
421
SELECT * from t2;
422
a
423
2
424
DROP TABLE t1,t2;
685.4.9 by Jay Pipes
multi_update.test now working. Removed VIEWs and other stuff, validated result
425
create table `t1` (`p_id` int NOT NULL auto_increment, `p_code` varchar(20) NOT NULL default '', `p_active` int NOT NULL default '1', PRIMARY KEY (`p_id`) );
426
create table `t2` (`c2_id` int NULL auto_increment, `c2_p_id` int NOT NULL default '0', `c2_note` text NOT NULL, `c2_active` int NOT NULL default '1', PRIMARY KEY (`c2_id`), KEY `c2_p_id` (`c2_p_id`) );
1 by brian
clean slate
427
insert into t1 values (0,'A01-Comp',1);
428
insert into t1 values (0,'B01-Comp',1);
429
insert into t2 values (0,1,'A Note',1);
430
update t1 left join t2 on p_id = c2_p_id set c2_note = 'asdf-1' where p_id = 2;
431
select * from t1;
432
p_id	p_code	p_active
433
1	A01-Comp	1
434
2	B01-Comp	1
435
select * from t2;
436
c2_id	c2_p_id	c2_note	c2_active
437
1	1	A Note	1
438
drop table t1, t2;
439
create table t1 (a int, primary key (a));
440
create table t2 (a int, primary key (a));
441
create table t3 (a int, primary key (a));
442
delete t1,t3 from t1,t2 where t1.a=t2.a and t2.a=(select t3.a from t3 where t1.a=t3.a);
443
ERROR 42S02: Unknown table 't3' in MULTI DELETE
444
drop table t1, t2, t3;
445
create table t1 (col1 int);
446
create table t2 (col1 int);
447
update t1,t2 set t1.col1 = (select max(col1) from t1) where t1.col1 = t2.col1;
448
ERROR HY000: You can't specify target table 't1' for update in FROM clause
449
delete t1 from t1,t2 where t1.col1 < (select max(col1) from t1) and t1.col1 = t2.col1;
450
ERROR HY000: You can't specify target table 't1' for update in FROM clause
451
drop table t1,t2;
452
create table t1 (
453
aclid bigint not null primary key, 
685.4.9 by Jay Pipes
multi_update.test now working. Removed VIEWs and other stuff, validated result
454
status int not null 
1 by brian
clean slate
455
) engine = innodb;
456
create table t2 (
457
refid bigint not null primary key, 
458
aclid bigint, index idx_acl(aclid) 
459
) engine = innodb;
460
insert into t2 values(1,null);
461
delete t2, t1 from t2 left join t1 on (t2.aclid=t1.aclid) where t2.refid='1';
462
drop table t1, t2;
463
create table t1(a int);
464
create table t2(a int);
465
delete from t1,t2 using t1,t2 where t1.a=(select a from t1);
466
ERROR HY000: You can't specify target table 't1' for update in FROM clause
467
drop table t1, t2;
468
create table t1 ( c char(8) not null ) engine=innodb;
469
insert into t1 values ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7'),('8'),('9');
470
insert into t1 values ('A'),('B'),('C'),('D'),('E'),('F');
471
alter table t1 add b char(8) not null;
472
alter table t1 add a char(8) not null;
473
alter table t1 add primary key (a,b,c);
474
update t1 set a=c, b=c;
475
create table t2 like t1;
476
insert into t2 select * from t1;
477
delete t1,t2 from t2,t1 where t1.a<'B' and t2.b=t1.b;
478
drop table t1,t2;
479
create table t1 ( c char(8) not null ) engine=innodb;
480
insert into t1 values ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7'),('8'),('9');
481
insert into t1 values ('A'),('B'),('C'),('D'),('E'),('F');
482
alter table t1 add b char(8) not null;
483
alter table t1 add a char(8) not null;
484
alter table t1 add primary key (a,b,c);
485
update t1 set a=c, b=c;
486
create table t2 like t1;
487
insert into t2 select * from t1;
488
delete t1,t2 from t2,t1 where t1.a<'B' and t2.b=t1.b;
489
drop table t1,t2;
490
create table t1 (a int, b int);
491
insert into t1 values (1, 2), (2, 3), (3, 4);
492
create table t2 (a int);
493
insert into t2 values (10), (20), (30);
685.4.9 by Jay Pipes
multi_update.test now working. Removed VIEWs and other stuff, validated result
494
create table v1 as select a as b, a/10 as a from t2;
1 by brian
clean slate
495
lock table t1 write;
496
alter table t1 add column c int default 100 after a;
497
update t1, v1 set t1.b=t1.a+t1.b+v1.b where t1.a=v1.a;
498
unlock tables;
499
select * from t1;
500
a	c	b
501
1	100	13
502
2	100	25
503
3	100	37
504
select * from t2;
505
a
506
10
507
20
508
30
685.4.9 by Jay Pipes
multi_update.test now working. Removed VIEWs and other stuff, validated result
509
drop table v1;
1 by brian
clean slate
510
drop table t1, t2;
511
create table t1 (i1 int, i2 int, i3 int);
512
create table t2 (id int, c1 varchar(20), c2 varchar(20));
513
insert into t1 values (1,5,10),(3,7,12),(4,5,2),(9,10,15),(2,2,2);
514
insert into t2 values (9,"abc","def"),(5,"opq","lmn"),(2,"test t","t test");
515
select * from t1 order by i1;
516
i1	i2	i3
517
1	5	10
518
2	2	2
519
3	7	12
520
4	5	2
521
9	10	15
522
select * from t2;
523
id	c1	c2
524
9	abc	def
525
5	opq	lmn
526
2	test t	t test
527
update t1,t2 set t1.i2=15, t2.c2="ppc" where t1.i1=t2.id;
528
select * from t1 order by i1;
529
i1	i2	i3
530
1	5	10
531
2	15	2
532
3	7	12
533
4	5	2
534
9	15	15
535
select * from t2 order by id;
536
id	c1	c2
537
2	test t	ppc
538
5	opq	lmn
539
9	abc	ppc
540
delete t1.*,t2.* from t1,t2 where t1.i2=t2.id;
541
select * from t1 order by i1;
542
i1	i2	i3
543
2	15	2
544
3	7	12
545
9	15	15
546
select * from t2 order by id;
547
id	c1	c2
548
2	test t	ppc
549
9	abc	ppc
550
drop table t1, t2;
551
create table t1 (i1 int auto_increment not null, i2 int, i3 int, primary key (i1));
552
create table t2 (id int auto_increment not null, c1 varchar(20), c2 varchar(20), primary key(id));
553
insert into t1 values (1,5,10),(3,7,12),(4,5,2),(9,10,15),(2,2,2);
554
insert into t2 values (9,"abc","def"),(5,"opq","lmn"),(2,"test t","t test");
555
select * from t1 order by i1;
556
i1	i2	i3
557
1	5	10
558
2	2	2
559
3	7	12
560
4	5	2
561
9	10	15
562
select * from t2 order by id;
563
id	c1	c2
564
2	test t	t test
565
5	opq	lmn
566
9	abc	def
567
update t1,t2 set t1.i2=15, t2.c2="ppc" where t1.i1=t2.id;
568
select * from t1 order by i1;
569
i1	i2	i3
570
1	5	10
571
2	15	2
572
3	7	12
573
4	5	2
574
9	15	15
575
select * from t2 order by id;
576
id	c1	c2
577
2	test t	ppc
578
5	opq	lmn
579
9	abc	ppc
580
delete t1.*,t2.* from t1,t2 where t1.i2=t2.id;
581
select * from t1 order by i1;
582
i1	i2	i3
583
2	15	2
584
3	7	12
585
9	15	15
586
select * from t2 order by id;
587
id	c1	c2
588
2	test t	ppc
589
9	abc	ppc
590
drop table t1, t2;
591
end of tests