1
drop table if exists t1,t2;
2
drop database if exists mysqltest;
4
col1 int not null auto_increment primary key,
5
col2 varchar(30) not null,
6
col3 varchar (20) not null,
7
col4 varchar(4) not null,
8
col5 enum('PENDING', 'ACTIVE', 'DISABLED') not null,
9
col6 int not null, to_be_deleted int);
10
insert into t1 values (2,4,3,5,"PENDING",1,7);
12
ADD COLUMN col4_5 varchar(20) DEFAULT "cat" not null after col4,
13
ADD COLUMN col7 varchar(30) DEFAULT "dog" not null after col5,
14
ADD COLUMN col8 datetime not null default '1000-01-01 00:00:00', drop column to_be_deleted,
15
change column col2 fourth varchar(30) not null after col3,
16
modify column col6 int not null first;
18
col6 col1 col3 fourth col4 col4_5 col5 col7 col8
19
1 2 3 4 5 cat PENDING dog 1000-01-01 00:00:00
21
create table t1 (bandID INT NOT NULL PRIMARY KEY, payoutID int NOT NULL);
22
insert into t1 (bandID,payoutID) VALUES (1,6),(2,6),(3,4),(4,9),(5,10),(6,1),(7,12),(8,12);
23
alter table t1 add column new_col int;
25
bandID payoutID new_col
36
bandID payoutID new_col
47
GROUP_ID int DEFAULT '0' NOT NULL,
48
LANG_ID int DEFAULT '0' NOT NULL,
49
NAME varchar(80) DEFAULT '' NOT NULL,
50
PRIMARY KEY (GROUP_ID,LANG_ID),
52
ALTER TABLE t1 CHANGE NAME NAME CHAR(80) not null;
54
Field Type Null Default Default_is_NULL On_Update
55
GROUP_ID INTEGER NO 0 NO
56
LANG_ID INTEGER NO 0 NO
59
create table t1 (n int);
60
insert into t1 values(9),(3),(12),(10);
61
alter table t1 order by n;
69
CREATE TEMPORARY TABLE t1 (
70
id int NOT NULL default '0',
71
category_id int NOT NULL default '0',
72
type_id int NOT NULL default '0',
74
user_id int NOT NULL default '0',
75
status enum('new','old') NOT NULL default 'new',
78
ALTER TABLE t1 ORDER BY t1.id, t1.status, t1.type_id, t1.user_id, t1.body;
80
create table t1 (i int not null auto_increment primary key);
81
insert into t1 values (null),(null),(null),(null);
82
alter table t1 drop i,add i int not null auto_increment, drop primary key, add primary key (i);
90
create table t1 (name char(15));
91
insert into t1 (name) values ("current");
92
create database mysqltest;
93
create table mysqltest.t1 (name char(15));
94
insert into mysqltest.t1 (name) values ("mysqltest");
98
select * from mysqltest.t1;
101
alter table t1 rename mysqltest.t1;
102
ERROR 42S01: Table 'mysqltest.t1' already exists
106
select * from mysqltest.t1;
110
drop database mysqltest;
111
create table t1 (n1 int not null, n2 int, n3 int, n4 float,
113
key (n1, n2, n3, n4),
114
key (n2, n3, n4, n1),
115
key (n3, n4, n1, n2),
116
key (n4, n1, n2, n3) );
119
Table Unique Key_name Seq_in_index Column_name
139
insert into t1 values(10,RAND()*1000,RAND()*1000,RAND());
140
insert into t1 values(9,RAND()*1000,RAND()*1000,RAND());
141
insert into t1 values(8,RAND()*1000,RAND()*1000,RAND());
142
insert into t1 values(7,RAND()*1000,RAND()*1000,RAND());
143
insert into t1 values(6,RAND()*1000,RAND()*1000,RAND());
144
insert into t1 values(5,RAND()*1000,RAND()*1000,RAND());
145
insert into t1 values(4,RAND()*1000,RAND()*1000,RAND());
146
insert into t1 values(3,RAND()*1000,RAND()*1000,RAND());
147
insert into t1 values(2,RAND()*1000,RAND()*1000,RAND());
148
insert into t1 values(1,RAND()*1000,RAND()*1000,RAND());
151
alter table t1 enable keys;
153
Note 1031 Table storage engine for 't1' doesn't have this option
155
Table Unique Key_name Seq_in_index Column_name
174
create table t1 (i int not null auto_increment primary key);
175
alter table t1 rename t2;
176
alter table t2 rename t1, add c char(10) comment "no comment";
177
show columns from t1;
178
Field Type Null Default Default_is_NULL On_Update
182
create table t1 (a int, b int);
185
insert into t1 values(1,100), (2,100), (3, 100);
186
insert into t1 values(1,99), (2,99), (3, 99);
187
insert into t1 values(1,98), (2,98), (3, 98);
188
insert into t1 values(1,97), (2,97), (3, 97);
189
insert into t1 values(1,96), (2,96), (3, 96);
190
insert into t1 values(1,95), (2,95), (3, 95);
191
insert into t1 values(1,94), (2,94), (3, 94);
192
insert into t1 values(1,93), (2,93), (3, 93);
193
insert into t1 values(1,92), (2,92), (3, 92);
194
insert into t1 values(1,91), (2,91), (3, 91);
195
insert into t1 values(1,90), (2,90), (3, 90);
196
insert into t1 values(1,89), (2,89), (3, 89);
197
insert into t1 values(1,88), (2,88), (3, 88);
198
insert into t1 values(1,87), (2,87), (3, 87);
199
insert into t1 values(1,86), (2,86), (3, 86);
200
insert into t1 values(1,85), (2,85), (3, 85);
201
insert into t1 values(1,84), (2,84), (3, 84);
202
insert into t1 values(1,83), (2,83), (3, 83);
203
insert into t1 values(1,82), (2,82), (3, 82);
204
insert into t1 values(1,81), (2,81), (3, 81);
205
insert into t1 values(1,80), (2,80), (3, 80);
206
insert into t1 values(1,79), (2,79), (3, 79);
207
insert into t1 values(1,78), (2,78), (3, 78);
208
insert into t1 values(1,77), (2,77), (3, 77);
209
insert into t1 values(1,76), (2,76), (3, 76);
210
insert into t1 values(1,75), (2,75), (3, 75);
211
insert into t1 values(1,74), (2,74), (3, 74);
212
insert into t1 values(1,73), (2,73), (3, 73);
213
insert into t1 values(1,72), (2,72), (3, 72);
214
insert into t1 values(1,71), (2,71), (3, 71);
215
insert into t1 values(1,70), (2,70), (3, 70);
216
insert into t1 values(1,69), (2,69), (3, 69);
217
insert into t1 values(1,68), (2,68), (3, 68);
218
insert into t1 values(1,67), (2,67), (3, 67);
219
insert into t1 values(1,66), (2,66), (3, 66);
220
insert into t1 values(1,65), (2,65), (3, 65);
221
insert into t1 values(1,64), (2,64), (3, 64);
222
insert into t1 values(1,63), (2,63), (3, 63);
223
insert into t1 values(1,62), (2,62), (3, 62);
224
insert into t1 values(1,61), (2,61), (3, 61);
225
insert into t1 values(1,60), (2,60), (3, 60);
226
insert into t1 values(1,59), (2,59), (3, 59);
227
insert into t1 values(1,58), (2,58), (3, 58);
228
insert into t1 values(1,57), (2,57), (3, 57);
229
insert into t1 values(1,56), (2,56), (3, 56);
230
insert into t1 values(1,55), (2,55), (3, 55);
231
insert into t1 values(1,54), (2,54), (3, 54);
232
insert into t1 values(1,53), (2,53), (3, 53);
233
insert into t1 values(1,52), (2,52), (3, 52);
234
insert into t1 values(1,51), (2,51), (3, 51);
235
insert into t1 values(1,50), (2,50), (3, 50);
236
insert into t1 values(1,49), (2,49), (3, 49);
237
insert into t1 values(1,48), (2,48), (3, 48);
238
insert into t1 values(1,47), (2,47), (3, 47);
239
insert into t1 values(1,46), (2,46), (3, 46);
240
insert into t1 values(1,45), (2,45), (3, 45);
241
insert into t1 values(1,44), (2,44), (3, 44);
242
insert into t1 values(1,43), (2,43), (3, 43);
243
insert into t1 values(1,42), (2,42), (3, 42);
244
insert into t1 values(1,41), (2,41), (3, 41);
245
insert into t1 values(1,40), (2,40), (3, 40);
246
insert into t1 values(1,39), (2,39), (3, 39);
247
insert into t1 values(1,38), (2,38), (3, 38);
248
insert into t1 values(1,37), (2,37), (3, 37);
249
insert into t1 values(1,36), (2,36), (3, 36);
250
insert into t1 values(1,35), (2,35), (3, 35);
251
insert into t1 values(1,34), (2,34), (3, 34);
252
insert into t1 values(1,33), (2,33), (3, 33);
253
insert into t1 values(1,32), (2,32), (3, 32);
254
insert into t1 values(1,31), (2,31), (3, 31);
255
insert into t1 values(1,30), (2,30), (3, 30);
256
insert into t1 values(1,29), (2,29), (3, 29);
257
insert into t1 values(1,28), (2,28), (3, 28);
258
insert into t1 values(1,27), (2,27), (3, 27);
259
insert into t1 values(1,26), (2,26), (3, 26);
260
insert into t1 values(1,25), (2,25), (3, 25);
261
insert into t1 values(1,24), (2,24), (3, 24);
262
insert into t1 values(1,23), (2,23), (3, 23);
263
insert into t1 values(1,22), (2,22), (3, 22);
264
insert into t1 values(1,21), (2,21), (3, 21);
265
insert into t1 values(1,20), (2,20), (3, 20);
266
insert into t1 values(1,19), (2,19), (3, 19);
267
insert into t1 values(1,18), (2,18), (3, 18);
268
insert into t1 values(1,17), (2,17), (3, 17);
269
insert into t1 values(1,16), (2,16), (3, 16);
270
insert into t1 values(1,15), (2,15), (3, 15);
271
insert into t1 values(1,14), (2,14), (3, 14);
272
insert into t1 values(1,13), (2,13), (3, 13);
273
insert into t1 values(1,12), (2,12), (3, 12);
274
insert into t1 values(1,11), (2,11), (3, 11);
275
insert into t1 values(1,10), (2,10), (3, 10);
276
insert into t1 values(1,9), (2,9), (3, 9);
277
insert into t1 values(1,8), (2,8), (3, 8);
278
insert into t1 values(1,7), (2,7), (3, 7);
279
insert into t1 values(1,6), (2,6), (3, 6);
280
insert into t1 values(1,5), (2,5), (3, 5);
281
insert into t1 values(1,4), (2,4), (3, 4);
282
insert into t1 values(1,3), (2,3), (3, 3);
283
insert into t1 values(1,2), (2,2), (3, 2);
284
insert into t1 values(1,1), (2,1), (3, 1);
287
alter table t1 add unique (a,b), add key (b);
289
Table Unique Key_name Seq_in_index Column_name
294
Table Op Msg_type Msg_text
295
test.t1 analyze status OK
297
Table Unique Key_name Seq_in_index Column_name
302
CREATE TEMPORARY TABLE t1 (
303
Host varchar(16) NOT NULL default '',
304
User varchar(16) NOT NULL default '',
305
PRIMARY KEY (Host,User),
308
ALTER TABLE t1 DISABLE KEYS;
309
INSERT INTO t1 VALUES ('localhost','root'),('localhost','');
310
ALTER TABLE t1 ENABLE KEYS;
312
Table Op Msg_type Msg_text
313
test.t1 check status OK
314
ALTER TABLE t1 RENAME t2;
320
create table t1 (a int);
321
alter table t1 rename to ``;
322
ERROR 42000: Incorrect table name ''
323
rename table t1 to ``;
324
ERROR 42000: Incorrect table name ''
326
drop table if exists t1;
328
Note 1051 Unknown table 't1'
329
create TEMPORARY table t1 ( a varchar(10) not null primary key ) engine=myisam;
331
alter table t1 modify a varchar(10);
333
alter table t1 modify a varchar(10) not null;
334
drop table if exists t1;
335
create TEMPORARY table t1 (a int, b int, c int, d int, e int, f int, g int, h int,i int, primary key (a,b,c,d,e,f,g,i,h)) engine=MyISAM;
336
insert into t1 (a,b,c,d,e,f,g,h,i) values(1,1,1,1,1,1,1,1,1);
337
show table status like 't1';
338
Session Schema Name Type Engine Version Rows Avg_row_length Table_size Auto_increment
339
# test t1 TEMPORARY MyISAM # # # # #
340
alter table t1 modify a int;
341
show table status like 't1';
342
Session Schema Name Type Engine Version Rows Avg_row_length Table_size Auto_increment
343
# test t1 TEMPORARY MyISAM # # # # #
345
create TEMPORARY table t1 (a int not null default 0, b int not null default 0, c int not null default 0, d int not null default 0, e int not null default 0, f int not null default 0, g int not null default 0, h int not null default 0,i int not null default 0, primary key (a,b,c,d,e,f,g,i,h)) engine=MyISAM;
346
insert into t1 (a) values(1);
347
show table status like 't1';
348
Session Schema Name Type Engine Version Rows Avg_row_length Table_size Auto_increment
349
# test t1 TEMPORARY MyISAM # # # # #
351
CREATE TABLE t1 (a int PRIMARY KEY, b INT UNIQUE);
352
ALTER TABLE t1 DROP PRIMARY KEY;
353
SHOW CREATE TABLE t1;
355
t1 CREATE TABLE `t1` (
357
`b` INT DEFAULT NULL,
358
UNIQUE KEY `b` (`b`) USING BTREE
359
) ENGINE=DEFAULT COLLATE = utf8_general_ci
360
ALTER TABLE t1 DROP PRIMARY KEY;
361
ERROR 42000: Can't DROP 'PRIMARY'; check that column/key exists
363
create table t1 (a int, b int, key(a));
364
insert into t1 values (1,1), (2,2);
365
alter table t1 drop key no_such_key;
366
ERROR 42000: Can't DROP 'no_such_key'; check that column/key exists
367
alter table t1 drop key a;
369
CREATE TEMPORARY TABLE T12207(a int) ENGINE=MYISAM;
370
ALTER TABLE T12207 DISCARD TABLESPACE;
371
ERROR HY000: Table storage engine for 'T12207' doesn't have this option
373
create table t1 ( a timestamp );
374
alter table t1 add unique ( a(1) );
375
ERROR HY000: Incorrect prefix key; the used key part isn't a string, the used length is longer than the key part, or the storage engine doesn't support unique prefix keys
377
drop table if exists t1;
378
create table t1 (a int, key(a));
379
show indexes from t1;
380
Table Unique Key_name Seq_in_index Column_name
382
"this used not to disable the index"
383
alter table t1 modify a int;
384
show indexes from t1;
385
Table Unique Key_name Seq_in_index Column_name
387
alter table t1 enable keys;
389
Note 1031 Table storage engine for 't1' doesn't have this option
390
show indexes from t1;
391
Table Unique Key_name Seq_in_index Column_name
393
alter table t1 modify a bigint;
394
show indexes from t1;
395
Table Unique Key_name Seq_in_index Column_name
397
alter table t1 enable keys;
399
Note 1031 Table storage engine for 't1' doesn't have this option
400
show indexes from t1;
401
Table Unique Key_name Seq_in_index Column_name
403
alter table t1 add b char(10);
404
show indexes from t1;
405
Table Unique Key_name Seq_in_index Column_name
407
alter table t1 add c decimal(10,2);
408
show indexes from t1;
409
Table Unique Key_name Seq_in_index Column_name
413
show indexes from t1;
414
Table Unique Key_name Seq_in_index Column_name
417
Field Type Null Default Default_is_NULL On_Update
421
alter table t1 add d decimal(15,5);
422
"The key should still be disabled"
423
show indexes from t1;
424
Table Unique Key_name Seq_in_index Column_name
427
"Now will test with one unique index"
428
create table t1(a int, b char(10), unique(a));
429
show indexes from t1;
430
Table Unique Key_name Seq_in_index Column_name
433
show indexes from t1;
434
Table Unique Key_name Seq_in_index Column_name
436
alter table t1 enable keys;
438
Note 1031 Table storage engine for 't1' doesn't have this option
439
"If no copy on noop change, this won't touch the data file"
440
"Unique index, no change"
441
alter table t1 modify a int;
442
show indexes from t1;
443
Table Unique Key_name Seq_in_index Column_name
445
"Change the type implying data copy"
446
"Unique index, no change"
447
alter table t1 modify a bigint;
448
show indexes from t1;
449
Table Unique Key_name Seq_in_index Column_name
451
alter table t1 modify a bigint;
452
show indexes from t1;
453
Table Unique Key_name Seq_in_index Column_name
455
alter table t1 modify a int;
456
show indexes from t1;
457
Table Unique Key_name Seq_in_index Column_name
460
"Now will test with one unique and one non-unique index"
461
create table t1(a int, b char(10), unique(a), key(b));
462
show indexes from t1;
463
Table Unique Key_name Seq_in_index Column_name
467
show indexes from t1;
468
Table Unique Key_name Seq_in_index Column_name
471
alter table t1 enable keys;
473
Note 1031 Table storage engine for 't1' doesn't have this option
474
"If no copy on noop change, this won't touch the data file"
475
"The non-unique index will be disabled"
476
alter table t1 modify a int;
477
show indexes from t1;
478
Table Unique Key_name Seq_in_index Column_name
481
alter table t1 enable keys;
483
Note 1031 Table storage engine for 't1' doesn't have this option
484
show indexes from t1;
485
Table Unique Key_name Seq_in_index Column_name
488
"Change the type implying data copy"
489
"The non-unique index will be disabled"
490
alter table t1 modify a bigint;
491
show indexes from t1;
492
Table Unique Key_name Seq_in_index Column_name
495
"Change again the type, but leave the indexes as_is"
496
alter table t1 modify a int;
497
show indexes from t1;
498
Table Unique Key_name Seq_in_index Column_name
501
"Try the same. When data is no copied on similar tables, this is noop"
502
alter table t1 modify a int;
503
show indexes from t1;
504
Table Unique Key_name Seq_in_index Column_name
508
create database mysqltest;
509
create table t1 (c1 int);
510
alter table t1 rename mysqltest.t1;
512
ERROR 42S02: Unknown table 't1'
513
alter table mysqltest.t1 rename t1;
515
create table t1 (c1 int);
517
drop database mysqltest;
518
alter table test.t1 rename t1;
519
ERROR 3D000: No schema selected
520
alter table test.t1 rename test.t1;
523
CREATE TABLE t1(a INT) ROW_FORMAT=COMPACT;
524
CREATE INDEX i1 ON t1(a);
525
SHOW CREATE TABLE t1;
527
t1 CREATE TABLE `t1` (
528
`a` INT DEFAULT NULL,
529
KEY `i1` (`a`) USING BTREE
530
) ENGINE=DEFAULT ROW_FORMAT='COMPACT' COLLATE = utf8_general_ci
532
SHOW CREATE TABLE t1;
534
t1 CREATE TABLE `t1` (
536
) ENGINE=DEFAULT ROW_FORMAT='COMPACT' COLLATE = utf8_general_ci
538
DROP TABLE IF EXISTS bug24219;
539
DROP TABLE IF EXISTS bug24219_2;
540
CREATE TABLE bug24219 (a INT, INDEX(a));
541
SHOW INDEX FROM bug24219;
542
Table Unique Key_name Seq_in_index Column_name
544
ALTER TABLE bug24219 RENAME TO bug24219_2, DISABLE KEYS;
546
Note 1031 Table storage engine for 'bug24219' doesn't have this option
547
SHOW INDEX FROM bug24219_2;
548
Table Unique Key_name Seq_in_index Column_name
550
DROP TABLE bug24219_2;
551
drop table if exists table_24562;
552
create table table_24562(
556
insert into table_24562 values
557
(1, 0, "Introduction"),
559
(1, 2, "Acknowledgements"),
564
(3, 0, "Intermediate"),
565
(3, 1, "Complex queries"),
566
(3, 2, "Stored Procedures"),
567
(3, 3, "Stored Functions"),
569
(4, 1, "Replication"),
570
(4, 2, "Load balancing"),
571
(4, 3, "High availability"),
572
(5, 0, "Conclusion");
573
select * from table_24562;
574
section subsection title
584
3 2 Stored Procedures
589
4 3 High availability
591
alter table table_24562 add column reviewer varchar(20),
593
select * from table_24562;
594
section subsection title reviewer
595
1 2 Acknowledgements NULL
600
3 1 Complex queries NULL
602
4 3 High availability NULL
603
3 0 Intermediate NULL
604
1 0 Introduction NULL
605
4 2 Load balancing NULL
608
3 3 Stored Functions NULL
609
3 2 Stored Procedures NULL
611
update table_24562 set reviewer="Me" where section=2;
612
update table_24562 set reviewer="You" where section=3;
613
alter table table_24562
614
order by section ASC, subsection DESC;
615
select * from table_24562;
616
section subsection title reviewer
617
1 2 Acknowledgements NULL
619
1 0 Introduction NULL
624
3 3 Stored Functions You
625
3 2 Stored Procedures You
626
3 1 Complex queries You
628
4 3 High availability NULL
629
4 2 Load balancing NULL
633
alter table table_24562
634
order by table_24562.subsection ASC, table_24562.section DESC;
635
select * from table_24562;
636
section subsection title reviewer
641
1 0 Introduction NULL
643
3 1 Complex queries You
646
4 2 Load balancing NULL
647
3 2 Stored Procedures You
649
1 2 Acknowledgements NULL
650
4 3 High availability NULL
651
3 3 Stored Functions You
653
alter table table_24562 order by 12;
654
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 '12' at line 1
655
alter table table_24562 order by (section + 12);
656
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 '(section + 12)' at line 1
657
alter table table_24562 order by length(title);
658
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 '(title)' at line 1
659
alter table table_24562 order by no_such_col;
660
ERROR 42S22: Unknown column 'no_such_col' in 'order clause'
661
drop table table_24562;
662
create table t1 (mycol int not null);
663
alter table t1 alter column mycol set default 0;
665
Field Type Null Default Default_is_NULL On_Update
666
mycol INTEGER NO 0 NO
668
create TEMPORARY table t1(id int primary key auto_increment) engine=MEMORY;
669
insert into t1 values (null);
670
insert into t1 values (null);
675
alter table t1 auto_increment = 50;
676
alter table t1 engine = myisam;
677
insert into t1 values (null);
683
alter table t1 engine = MEMORY;
684
insert into t1 values (null);
692
create table t1 (v varchar(32));
693
insert into t1 values ('def'),('abc'),('hij'),('3r4f');
700
alter table t1 change v v2 varchar(32);
707
alter table t1 change v2 v varchar(64);
714
update t1 set v = 'lmn' where v = 'hij';
721
alter table t1 add i int auto_increment not null primary key first;
728
update t1 set i=5 where i=3;
735
alter table t1 change i i bigint;
742
alter table t1 add unique key (i, v);
743
select * from t1 where i between 2 and 4 and v in ('def','3r4f','lmn');
747
create TEMPORARY table t1 (t varchar(255) default null, key t (t(80))) engine=myisam;
748
alter table t1 change t t text;
750
CREATE TABLE t1 (s CHAR(8));
751
INSERT INTO t1 VALUES ('test');
752
SELECT LENGTH(s) FROM t1;
755
ALTER TABLE t1 MODIFY s CHAR(10);
756
SELECT LENGTH(s) FROM t1;
760
CREATE TABLE t1 (s varbinary(8));
761
INSERT INTO t1 VALUES ('test');
762
SELECT LENGTH(s) FROM t1;
765
SELECT HEX(s) FROM t1;
768
ALTER TABLE t1 MODIFY s varbinary(10);
769
SELECT HEX(s) FROM t1;
772
SELECT LENGTH(s) FROM t1;
776
CREATE TABLE t1 (v VARCHAR(3), b INT);
777
INSERT INTO t1 VALUES ('abc', 5);
781
ALTER TABLE t1 MODIFY COLUMN v VARCHAR(4);
787
DROP TABLE IF EXISTS `t+1`, `t+2`;
788
CREATE TABLE `t+1` (c1 INT);
789
ALTER TABLE `t+1` RENAME `t+2`;
790
CREATE TABLE `t+1` (c1 INT);
791
ALTER TABLE `t+1` RENAME `t+2`;
792
ERROR 42S01: Table 'test.t+2' already exists
793
DROP TABLE `t+1`, `t+2`;
794
CREATE TEMPORARY TABLE `tt+1` (c1 INT);
795
ALTER TABLE `tt+1` RENAME `tt+2`;
796
CREATE TEMPORARY TABLE `tt+1` (c1 INT);
797
ALTER TABLE `tt+1` RENAME `tt+2`;
798
ERROR 42S01: Table 'test.#tt+2' already exists
799
SHOW CREATE TABLE `tt+1`;
801
tt+1 CREATE TEMPORARY TABLE `tt+1` (
802
`c1` INT DEFAULT NULL
803
) ENGINE=DEFAULT COLLATE = utf8_general_ci
804
SHOW CREATE TABLE `tt+2`;
806
tt+2 CREATE TEMPORARY TABLE `tt+2` (
807
`c1` INT DEFAULT NULL
808
) ENGINE=DEFAULT COLLATE = utf8_general_ci
809
DROP TABLE `tt+1`, `tt+2`;
810
CREATE TEMPORARY TABLE `#sql1` (c1 INT);
811
CREATE TEMPORARY TABLE `@0023sql2` (c1 INT);
816
ALTER TABLE `#sql1` RENAME `@0023sql1`;
817
ALTER TABLE `@0023sql2` RENAME `#sql2`;
822
INSERT INTO `#sql2` VALUES (1);
823
INSERT INTO `@0023sql1` VALUES (2);
824
SHOW CREATE TABLE `#sql2`;
826
#sql2 CREATE TEMPORARY TABLE `#sql2` (
827
`c1` INT DEFAULT NULL
828
) ENGINE=DEFAULT COLLATE = utf8_general_ci
829
SHOW CREATE TABLE `@0023sql1`;
831
@0023sql1 CREATE TEMPORARY TABLE `@0023sql1` (
832
`c1` INT DEFAULT NULL
833
) ENGINE=DEFAULT COLLATE = utf8_general_ci
834
DROP TABLE `#sql2`, `@0023sql1`;
835
DROP TABLE IF EXISTS t1;
836
DROP TABLE IF EXISTS t2;
838
int_field INTEGER NOT NULL,
843
Field Type Null Default Default_is_NULL On_Update
844
int_field INTEGER NO NO
845
char_field VARCHAR YES YES
846
SHOW INDEXES FROM t1;
847
Table Unique Key_name Seq_in_index Column_name
848
t1 NO int_field 1 int_field
849
INSERT INTO t1 VALUES (1, "edno"), (1, "edno"), (2, "dve"), (3, "tri"), (5, "pet");
850
"Non-copy data change - new frm, but old data and index files"
851
ALTER TABLE t1 CHANGE int_field unsigned_int_field INTEGER NOT NULL, RENAME t2;
852
SELECT * FROM t1 ORDER BY int_field;
853
ERROR 42S02: Unknown table 'test.t1'
854
SELECT * FROM t2 ORDER BY unsigned_int_field;
855
unsigned_int_field char_field
862
Field Type Null Default Default_is_NULL On_Update
863
unsigned_int_field INTEGER NO NO
864
char_field VARCHAR YES YES
866
Field Type Null Default Default_is_NULL On_Update
867
unsigned_int_field INTEGER NO NO
868
char_field VARCHAR YES YES
869
ALTER TABLE t2 MODIFY unsigned_int_field BIGINT NOT NULL;
871
Field Type Null Default Default_is_NULL On_Update
872
unsigned_int_field BIGINT NO NO
873
char_field VARCHAR YES YES
875
CREATE TABLE t1 (f1 INT, f2 INT, f3 INT);
876
INSERT INTO t1 VALUES (1, 2, NULL);
880
ALTER TABLE t1 MODIFY COLUMN f3 INT AFTER f1;
884
ALTER TABLE t1 MODIFY COLUMN f3 INT AFTER f2;