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
col1 col2 col3 col4 col5 col6 to_be_deleted
15
add column col4_5 varchar(20) not null after col4,
16
add column col7 varchar(30) not null after col5,
17
add column col8 datetime not null default '1000-01-01 00:00:00', drop column to_be_deleted,
18
change column col2 fourth varchar(30) not null after col3,
19
modify column col6 int not null first;
20
ERROR HY000: Either a DEFAULt value or NULL NULL description is required for a new column if table is not empty
22
add column col4_5 varchar(20) DEFAULT "added" not null after col4,
23
add column col7 varchar(30) DEFAULT "added" not null after col5,
24
add column col8 datetime not null default '1000-01-01 00:00:00',
25
drop column to_be_deleted,
26
change column col2 fourth varchar(30) not null after col3,
27
modify column col6 int not null first;
29
col6 col1 col3 fourth col4 col4_5 col5 col7 col8
30
1 2 3 4 5 added PENDING added 1000-01-01 00:00:00
32
create table t1 (bandID INT NOT NULL PRIMARY KEY, payoutID int NOT NULL);
33
insert into t1 (bandID,payoutID) VALUES (1,6),(2,6),(3,4),(4,9),(5,10),(6,1),(7,12),(8,12);
34
alter table t1 add column new_col int;
36
bandID payoutID new_col
47
bandID payoutID new_col
58
GROUP_ID int DEFAULT '0' NOT NULL,
59
LANG_ID int DEFAULT '0' NOT NULL,
60
NAME varchar(80) DEFAULT '' NOT NULL,
61
PRIMARY KEY (GROUP_ID,LANG_ID),
63
ALTER TABLE t1 CHANGE NAME NAME CHAR(80) not null;
65
Field Type Null Default Default_is_NULL On_Update
66
GROUP_ID INTEGER NO 0 NO
67
LANG_ID INTEGER NO 0 NO
70
create table t1 (n int);
71
insert into t1 values(9),(3),(12),(10);
72
alter table t1 order by n;
80
CREATE TEMPORARY TABLE t1 (
81
id int NOT NULL default '0',
82
category_id int NOT NULL default '0',
83
type_id int NOT NULL default '0',
85
user_id int NOT NULL default '0',
86
status enum('new','old') NOT NULL default 'new',
89
ALTER TABLE t1 ORDER BY t1.id, t1.status, t1.type_id, t1.user_id, t1.body;
91
create table t1 (i int not null auto_increment primary key);
92
insert into t1 values (null),(null),(null),(null);
93
alter table t1 drop i,add i int not null auto_increment, drop primary key, add primary key (i);
101
create table t1 (name char(15));
102
insert into t1 (name) values ("current");
103
create database mysqltest;
104
create table mysqltest.t1 (name char(15));
105
insert into mysqltest.t1 (name) values ("mysqltest");
109
select * from mysqltest.t1;
112
alter table t1 rename mysqltest.t1;
113
ERROR 42S01: Table 'mysqltest.t1' already exists
117
select * from mysqltest.t1;
121
drop database mysqltest;
122
create table t1 (n1 int not null, n2 int, n3 int, n4 float,
124
key (n1, n2, n3, n4),
125
key (n2, n3, n4, n1),
126
key (n3, n4, n1, n2),
127
key (n4, n1, n2, n3) );
130
Table Unique Key_name Seq_in_index Column_name
150
insert into t1 values(10,RAND()*1000,RAND()*1000,RAND());
151
insert into t1 values(9,RAND()*1000,RAND()*1000,RAND());
152
insert into t1 values(8,RAND()*1000,RAND()*1000,RAND());
153
insert into t1 values(7,RAND()*1000,RAND()*1000,RAND());
154
insert into t1 values(6,RAND()*1000,RAND()*1000,RAND());
155
insert into t1 values(5,RAND()*1000,RAND()*1000,RAND());
156
insert into t1 values(4,RAND()*1000,RAND()*1000,RAND());
157
insert into t1 values(3,RAND()*1000,RAND()*1000,RAND());
158
insert into t1 values(2,RAND()*1000,RAND()*1000,RAND());
159
insert into t1 values(1,RAND()*1000,RAND()*1000,RAND());
162
alter table t1 enable keys;
164
Note 1031 Table storage engine for 't1' doesn't have this option
166
Table Unique Key_name Seq_in_index Column_name
185
create table t1 (i int not null auto_increment primary key);
186
alter table t1 rename t2;
187
alter table t2 rename t1, add c char(10) comment "no comment";
188
show columns from t1;
189
Field Type Null Default Default_is_NULL On_Update
193
create table t1 (a int, b int);
196
insert into t1 values(1,100), (2,100), (3, 100);
197
insert into t1 values(1,99), (2,99), (3, 99);
198
insert into t1 values(1,98), (2,98), (3, 98);
199
insert into t1 values(1,97), (2,97), (3, 97);
200
insert into t1 values(1,96), (2,96), (3, 96);
201
insert into t1 values(1,95), (2,95), (3, 95);
202
insert into t1 values(1,94), (2,94), (3, 94);
203
insert into t1 values(1,93), (2,93), (3, 93);
204
insert into t1 values(1,92), (2,92), (3, 92);
205
insert into t1 values(1,91), (2,91), (3, 91);
206
insert into t1 values(1,90), (2,90), (3, 90);
207
insert into t1 values(1,89), (2,89), (3, 89);
208
insert into t1 values(1,88), (2,88), (3, 88);
209
insert into t1 values(1,87), (2,87), (3, 87);
210
insert into t1 values(1,86), (2,86), (3, 86);
211
insert into t1 values(1,85), (2,85), (3, 85);
212
insert into t1 values(1,84), (2,84), (3, 84);
213
insert into t1 values(1,83), (2,83), (3, 83);
214
insert into t1 values(1,82), (2,82), (3, 82);
215
insert into t1 values(1,81), (2,81), (3, 81);
216
insert into t1 values(1,80), (2,80), (3, 80);
217
insert into t1 values(1,79), (2,79), (3, 79);
218
insert into t1 values(1,78), (2,78), (3, 78);
219
insert into t1 values(1,77), (2,77), (3, 77);
220
insert into t1 values(1,76), (2,76), (3, 76);
221
insert into t1 values(1,75), (2,75), (3, 75);
222
insert into t1 values(1,74), (2,74), (3, 74);
223
insert into t1 values(1,73), (2,73), (3, 73);
224
insert into t1 values(1,72), (2,72), (3, 72);
225
insert into t1 values(1,71), (2,71), (3, 71);
226
insert into t1 values(1,70), (2,70), (3, 70);
227
insert into t1 values(1,69), (2,69), (3, 69);
228
insert into t1 values(1,68), (2,68), (3, 68);
229
insert into t1 values(1,67), (2,67), (3, 67);
230
insert into t1 values(1,66), (2,66), (3, 66);
231
insert into t1 values(1,65), (2,65), (3, 65);
232
insert into t1 values(1,64), (2,64), (3, 64);
233
insert into t1 values(1,63), (2,63), (3, 63);
234
insert into t1 values(1,62), (2,62), (3, 62);
235
insert into t1 values(1,61), (2,61), (3, 61);
236
insert into t1 values(1,60), (2,60), (3, 60);
237
insert into t1 values(1,59), (2,59), (3, 59);
238
insert into t1 values(1,58), (2,58), (3, 58);
239
insert into t1 values(1,57), (2,57), (3, 57);
240
insert into t1 values(1,56), (2,56), (3, 56);
241
insert into t1 values(1,55), (2,55), (3, 55);
242
insert into t1 values(1,54), (2,54), (3, 54);
243
insert into t1 values(1,53), (2,53), (3, 53);
244
insert into t1 values(1,52), (2,52), (3, 52);
245
insert into t1 values(1,51), (2,51), (3, 51);
246
insert into t1 values(1,50), (2,50), (3, 50);
247
insert into t1 values(1,49), (2,49), (3, 49);
248
insert into t1 values(1,48), (2,48), (3, 48);
249
insert into t1 values(1,47), (2,47), (3, 47);
250
insert into t1 values(1,46), (2,46), (3, 46);
251
insert into t1 values(1,45), (2,45), (3, 45);
252
insert into t1 values(1,44), (2,44), (3, 44);
253
insert into t1 values(1,43), (2,43), (3, 43);
254
insert into t1 values(1,42), (2,42), (3, 42);
255
insert into t1 values(1,41), (2,41), (3, 41);
256
insert into t1 values(1,40), (2,40), (3, 40);
257
insert into t1 values(1,39), (2,39), (3, 39);
258
insert into t1 values(1,38), (2,38), (3, 38);
259
insert into t1 values(1,37), (2,37), (3, 37);
260
insert into t1 values(1,36), (2,36), (3, 36);
261
insert into t1 values(1,35), (2,35), (3, 35);
262
insert into t1 values(1,34), (2,34), (3, 34);
263
insert into t1 values(1,33), (2,33), (3, 33);
264
insert into t1 values(1,32), (2,32), (3, 32);
265
insert into t1 values(1,31), (2,31), (3, 31);
266
insert into t1 values(1,30), (2,30), (3, 30);
267
insert into t1 values(1,29), (2,29), (3, 29);
268
insert into t1 values(1,28), (2,28), (3, 28);
269
insert into t1 values(1,27), (2,27), (3, 27);
270
insert into t1 values(1,26), (2,26), (3, 26);
271
insert into t1 values(1,25), (2,25), (3, 25);
272
insert into t1 values(1,24), (2,24), (3, 24);
273
insert into t1 values(1,23), (2,23), (3, 23);
274
insert into t1 values(1,22), (2,22), (3, 22);
275
insert into t1 values(1,21), (2,21), (3, 21);
276
insert into t1 values(1,20), (2,20), (3, 20);
277
insert into t1 values(1,19), (2,19), (3, 19);
278
insert into t1 values(1,18), (2,18), (3, 18);
279
insert into t1 values(1,17), (2,17), (3, 17);
280
insert into t1 values(1,16), (2,16), (3, 16);
281
insert into t1 values(1,15), (2,15), (3, 15);
282
insert into t1 values(1,14), (2,14), (3, 14);
283
insert into t1 values(1,13), (2,13), (3, 13);
284
insert into t1 values(1,12), (2,12), (3, 12);
285
insert into t1 values(1,11), (2,11), (3, 11);
286
insert into t1 values(1,10), (2,10), (3, 10);
287
insert into t1 values(1,9), (2,9), (3, 9);
288
insert into t1 values(1,8), (2,8), (3, 8);
289
insert into t1 values(1,7), (2,7), (3, 7);
290
insert into t1 values(1,6), (2,6), (3, 6);
291
insert into t1 values(1,5), (2,5), (3, 5);
292
insert into t1 values(1,4), (2,4), (3, 4);
293
insert into t1 values(1,3), (2,3), (3, 3);
294
insert into t1 values(1,2), (2,2), (3, 2);
295
insert into t1 values(1,1), (2,1), (3, 1);
298
alter table t1 add unique (a,b), add key (b);
300
Table Unique Key_name Seq_in_index Column_name
305
Table Op Msg_type Msg_text
306
test.t1 analyze status OK
308
Table Unique Key_name Seq_in_index Column_name
313
CREATE TEMPORARY TABLE t1 (
314
Host varchar(16) NOT NULL default '',
315
User varchar(16) NOT NULL default '',
316
PRIMARY KEY (Host,User),
319
ALTER TABLE t1 DISABLE KEYS;
320
INSERT INTO t1 VALUES ('localhost','root'),('localhost','');
321
ALTER TABLE t1 ENABLE KEYS;
323
Table Op Msg_type Msg_text
324
test.t1 check status OK
325
ALTER TABLE t1 RENAME t2;
331
create table t1 (a int);
332
alter table t1 rename to ``;
333
ERROR 42000: Incorrect table name ''
334
rename table t1 to ``;
335
ERROR 42000: Incorrect table name ''
337
drop table if exists t1;
339
Note 1051 Unknown table 't1'
340
create TEMPORARY table t1 ( a varchar(10) not null primary key ) engine=myisam;
342
alter table t1 modify a varchar(10);
344
alter table t1 modify a varchar(10) not null;
345
drop table if exists t1;
346
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;
347
insert into t1 (a,b,c,d,e,f,g,h,i) values(1,1,1,1,1,1,1,1,1);
348
show table status like 't1';
349
Session Schema Name Type Engine Version Rows Avg_row_length Table_size Auto_increment
350
# test t1 TEMPORARY MyISAM # # # # #
351
alter table t1 modify a int;
352
show table status like 't1';
353
Session Schema Name Type Engine Version Rows Avg_row_length Table_size Auto_increment
354
# test t1 TEMPORARY MyISAM # # # # #
356
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;
357
insert into t1 (a) values(1);
358
show table status like 't1';
359
Session Schema Name Type Engine Version Rows Avg_row_length Table_size Auto_increment
360
# test t1 TEMPORARY MyISAM # # # # #
362
CREATE TABLE t1 (a int PRIMARY KEY, b INT UNIQUE);
363
ALTER TABLE t1 DROP PRIMARY KEY;
364
SHOW CREATE TABLE t1;
366
t1 CREATE TABLE `t1` (
368
`b` INT DEFAULT NULL,
370
) ENGINE=DEFAULT COLLATE = utf8_general_ci
371
ALTER TABLE t1 DROP PRIMARY KEY;
372
ERROR 42000: Can't DROP 'PRIMARY'; check that column/key exists
374
create table t1 (a int, b int, key(a));
375
insert into t1 values (1,1), (2,2);
376
alter table t1 drop key no_such_key;
377
ERROR 42000: Can't DROP 'no_such_key'; check that column/key exists
378
alter table t1 drop key a;
380
CREATE TEMPORARY TABLE T12207(a int) ENGINE=MYISAM;
381
ALTER TABLE T12207 DISCARD TABLESPACE;
382
ERROR HY000: Table storage engine for 'T12207' doesn't have this option
384
create table t1 ( a timestamp );
385
alter table t1 add unique ( a(1) );
386
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
388
drop table if exists t1;
389
create table t1 (a int, key(a));
390
show indexes from t1;
391
Table Unique Key_name Seq_in_index Column_name
393
"this used not to disable the index"
394
alter table t1 modify a int;
395
show indexes from t1;
396
Table Unique Key_name Seq_in_index Column_name
398
alter table t1 enable keys;
400
Note 1031 Table storage engine for 't1' doesn't have this option
401
show indexes from t1;
402
Table Unique Key_name Seq_in_index Column_name
404
alter table t1 modify a bigint;
405
show indexes from t1;
406
Table Unique Key_name Seq_in_index Column_name
408
alter table t1 enable keys;
410
Note 1031 Table storage engine for 't1' doesn't have this option
411
show indexes from t1;
412
Table Unique Key_name Seq_in_index Column_name
414
alter table t1 add b char(10);
415
show indexes from t1;
416
Table Unique Key_name Seq_in_index Column_name
418
alter table t1 add c decimal(10,2);
419
show indexes from t1;
420
Table Unique Key_name Seq_in_index Column_name
424
show indexes from t1;
425
Table Unique Key_name Seq_in_index Column_name
428
Field Type Null Default Default_is_NULL On_Update
432
alter table t1 add d decimal(15,5);
433
"The key should still be disabled"
434
show indexes from t1;
435
Table Unique Key_name Seq_in_index Column_name
438
"Now will test with one unique index"
439
create table t1(a int, b char(10), unique(a));
440
show indexes from t1;
441
Table Unique Key_name Seq_in_index Column_name
444
show indexes from t1;
445
Table Unique Key_name Seq_in_index Column_name
447
alter table t1 enable keys;
449
Note 1031 Table storage engine for 't1' doesn't have this option
450
"If no copy on noop change, this won't touch the data file"
451
"Unique index, no change"
452
alter table t1 modify a int;
453
show indexes from t1;
454
Table Unique Key_name Seq_in_index Column_name
456
"Change the type implying data copy"
457
"Unique index, no change"
458
alter table t1 modify a bigint;
459
show indexes from t1;
460
Table Unique Key_name Seq_in_index Column_name
462
alter table t1 modify a bigint;
463
show indexes from t1;
464
Table Unique Key_name Seq_in_index Column_name
466
alter table t1 modify a int;
467
show indexes from t1;
468
Table Unique Key_name Seq_in_index Column_name
471
"Now will test with one unique and one non-unique index"
472
create table t1(a int, b char(10), unique(a), key(b));
473
show indexes from t1;
474
Table Unique Key_name Seq_in_index Column_name
478
show indexes from t1;
479
Table Unique Key_name Seq_in_index Column_name
482
alter table t1 enable keys;
484
Note 1031 Table storage engine for 't1' doesn't have this option
485
"If no copy on noop change, this won't touch the data file"
486
"The non-unique index will be disabled"
487
alter table t1 modify a int;
488
show indexes from t1;
489
Table Unique Key_name Seq_in_index Column_name
492
alter table t1 enable keys;
494
Note 1031 Table storage engine for 't1' doesn't have this option
495
show indexes from t1;
496
Table Unique Key_name Seq_in_index Column_name
499
"Change the type implying data copy"
500
"The non-unique index will be disabled"
501
alter table t1 modify a bigint;
502
show indexes from t1;
503
Table Unique Key_name Seq_in_index Column_name
506
"Change again the type, but leave the indexes as_is"
507
alter table t1 modify a int;
508
show indexes from t1;
509
Table Unique Key_name Seq_in_index Column_name
512
"Try the same. When data is no copied on similar tables, this is noop"
513
alter table t1 modify a int;
514
show indexes from t1;
515
Table Unique Key_name Seq_in_index Column_name
519
create database mysqltest;
520
create table t1 (c1 int);
521
alter table t1 rename mysqltest.t1;
523
ERROR 42S02: Unknown table 't1'
524
alter table mysqltest.t1 rename t1;
526
create table t1 (c1 int);
528
drop database mysqltest;
529
alter table test.t1 rename t1;
530
ERROR 3D000: No schema selected
531
alter table test.t1 rename test.t1;
534
CREATE TABLE t1(a INT) ROW_FORMAT=COMPACT;
535
CREATE INDEX i1 ON t1(a);
536
SHOW CREATE TABLE t1;
538
t1 CREATE TABLE `t1` (
539
`a` INT DEFAULT NULL,
541
) ENGINE=DEFAULT ROW_FORMAT='COMPACT' COLLATE = utf8_general_ci
543
SHOW CREATE TABLE t1;
545
t1 CREATE TABLE `t1` (
547
) ENGINE=DEFAULT ROW_FORMAT='COMPACT' COLLATE = utf8_general_ci
549
DROP TABLE IF EXISTS bug24219;
550
DROP TABLE IF EXISTS bug24219_2;
551
CREATE TABLE bug24219 (a INT, INDEX(a));
552
SHOW INDEX FROM bug24219;
553
Table Unique Key_name Seq_in_index Column_name
555
ALTER TABLE bug24219 RENAME TO bug24219_2, DISABLE KEYS;
557
Note 1031 Table storage engine for 'bug24219' doesn't have this option
558
SHOW INDEX FROM bug24219_2;
559
Table Unique Key_name Seq_in_index Column_name
561
DROP TABLE bug24219_2;
562
drop table if exists table_24562;
563
create table table_24562(
567
insert into table_24562 values
568
(1, 0, "Introduction"),
570
(1, 2, "Acknowledgements"),
575
(3, 0, "Intermediate"),
576
(3, 1, "Complex queries"),
577
(3, 2, "Stored Procedures"),
578
(3, 3, "Stored Functions"),
580
(4, 1, "Replication"),
581
(4, 2, "Load balancing"),
582
(4, 3, "High availability"),
583
(5, 0, "Conclusion");
584
select * from table_24562;
585
section subsection title
595
3 2 Stored Procedures
600
4 3 High availability
602
alter table table_24562 add column reviewer varchar(20),
604
select * from table_24562;
605
section subsection title reviewer
606
1 2 Acknowledgements NULL
611
3 1 Complex queries NULL
613
4 3 High availability NULL
614
3 0 Intermediate NULL
615
1 0 Introduction NULL
616
4 2 Load balancing NULL
619
3 3 Stored Functions NULL
620
3 2 Stored Procedures NULL
622
update table_24562 set reviewer="Me" where section=2;
623
update table_24562 set reviewer="You" where section=3;
624
alter table table_24562
625
order by section ASC, subsection DESC;
626
select * from table_24562;
627
section subsection title reviewer
628
1 2 Acknowledgements NULL
630
1 0 Introduction NULL
635
3 3 Stored Functions You
636
3 2 Stored Procedures You
637
3 1 Complex queries You
639
4 3 High availability NULL
640
4 2 Load balancing NULL
644
alter table table_24562
645
order by table_24562.subsection ASC, table_24562.section DESC;
646
select * from table_24562;
647
section subsection title reviewer
652
1 0 Introduction NULL
654
3 1 Complex queries You
657
4 2 Load balancing NULL
658
3 2 Stored Procedures You
660
1 2 Acknowledgements NULL
661
4 3 High availability NULL
662
3 3 Stored Functions You
664
alter table table_24562 order by 12;
665
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
666
alter table table_24562 order by (section + 12);
667
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
668
alter table table_24562 order by length(title);
669
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
670
alter table table_24562 order by no_such_col;
671
ERROR 42S22: Unknown column 'no_such_col' in 'order clause'
672
drop table table_24562;
673
create table t1 (mycol int not null);
674
alter table t1 alter column mycol set default 0;
676
Field Type Null Default Default_is_NULL On_Update
677
mycol INTEGER NO 0 NO
679
create TEMPORARY table t1(id int primary key auto_increment) engine=MEMORY;
680
insert into t1 values (null);
681
insert into t1 values (null);
686
alter table t1 auto_increment = 50;
687
alter table t1 engine = myisam;
688
insert into t1 values (null);
694
alter table t1 engine = MEMORY;
695
insert into t1 values (null);
703
create table t1 (v varchar(32));
704
insert into t1 values ('def'),('abc'),('hij'),('3r4f');
711
alter table t1 change v v2 varchar(32);
718
alter table t1 change v2 v varchar(64);
725
update t1 set v = 'lmn' where v = 'hij';
732
alter table t1 add i int auto_increment not null primary key first;
739
update t1 set i=5 where i=3;
746
alter table t1 change i i bigint;
753
alter table t1 add unique key (i, v);
754
select * from t1 where i between 2 and 4 and v in ('def','3r4f','lmn');
758
create TEMPORARY table t1 (t varchar(255) default null, key t (t(80))) engine=myisam;
759
alter table t1 change t t text;
761
CREATE TABLE t1 (s CHAR(8));
762
INSERT INTO t1 VALUES ('test');
763
SELECT LENGTH(s) FROM t1;
766
ALTER TABLE t1 MODIFY s CHAR(10);
767
SELECT LENGTH(s) FROM t1;
771
CREATE TABLE t1 (s varbinary(8));
772
INSERT INTO t1 VALUES ('test');
773
SELECT LENGTH(s) FROM t1;
776
SELECT HEX(s) FROM t1;
779
ALTER TABLE t1 MODIFY s varbinary(10);
780
SELECT HEX(s) FROM t1;
783
SELECT LENGTH(s) FROM t1;
787
CREATE TABLE t1 (v VARCHAR(3), b INT);
788
INSERT INTO t1 VALUES ('abc', 5);
792
ALTER TABLE t1 MODIFY COLUMN v VARCHAR(4);
798
DROP TABLE IF EXISTS `t+1`, `t+2`;
799
CREATE TABLE `t+1` (c1 INT);
800
ALTER TABLE `t+1` RENAME `t+2`;
801
CREATE TABLE `t+1` (c1 INT);
802
ALTER TABLE `t+1` RENAME `t+2`;
803
ERROR 42S01: Table 'test.t+2' already exists
804
DROP TABLE `t+1`, `t+2`;
805
CREATE TEMPORARY TABLE `tt+1` (c1 INT);
806
ALTER TABLE `tt+1` RENAME `tt+2`;
807
CREATE TEMPORARY TABLE `tt+1` (c1 INT);
808
ALTER TABLE `tt+1` RENAME `tt+2`;
809
ERROR 42S01: Table 'test.#tt+2' already exists
810
SHOW CREATE TABLE `tt+1`;
812
tt+1 CREATE TEMPORARY TABLE `tt+1` (
813
`c1` INT DEFAULT NULL
814
) ENGINE=DEFAULT COLLATE = utf8_general_ci
815
SHOW CREATE TABLE `tt+2`;
817
tt+2 CREATE TEMPORARY TABLE `tt+2` (
818
`c1` INT DEFAULT NULL
819
) ENGINE=DEFAULT COLLATE = utf8_general_ci
820
DROP TABLE `tt+1`, `tt+2`;
821
CREATE TEMPORARY TABLE `#sql1` (c1 INT);
822
CREATE TEMPORARY TABLE `@0023sql2` (c1 INT);
827
ALTER TABLE `#sql1` RENAME `@0023sql1`;
828
ALTER TABLE `@0023sql2` RENAME `#sql2`;
833
INSERT INTO `#sql2` VALUES (1);
834
INSERT INTO `@0023sql1` VALUES (2);
835
SHOW CREATE TABLE `#sql2`;
837
#sql2 CREATE TEMPORARY TABLE `#sql2` (
838
`c1` INT DEFAULT NULL
839
) ENGINE=DEFAULT COLLATE = utf8_general_ci
840
SHOW CREATE TABLE `@0023sql1`;
842
@0023sql1 CREATE TEMPORARY TABLE `@0023sql1` (
843
`c1` INT DEFAULT NULL
844
) ENGINE=DEFAULT COLLATE = utf8_general_ci
845
DROP TABLE `#sql2`, `@0023sql1`;
846
DROP TABLE IF EXISTS t1;
847
DROP TABLE IF EXISTS t2;
849
int_field INTEGER NOT NULL,
854
Field Type Null Default Default_is_NULL On_Update
855
int_field INTEGER NO NO
856
char_field VARCHAR YES YES
857
SHOW INDEXES FROM t1;
858
Table Unique Key_name Seq_in_index Column_name
859
t1 NO int_field 1 int_field
860
INSERT INTO t1 VALUES (1, "edno"), (1, "edno"), (2, "dve"), (3, "tri"), (5, "pet");
861
"Non-copy data change - new frm, but old data and index files"
862
ALTER TABLE t1 CHANGE int_field unsigned_int_field INTEGER NOT NULL, RENAME t2;
863
SELECT * FROM t1 ORDER BY int_field;
864
ERROR 42S02: Unknown table 'test.t1'
865
SELECT * FROM t2 ORDER BY unsigned_int_field;
866
unsigned_int_field char_field
873
Field Type Null Default Default_is_NULL On_Update
874
unsigned_int_field INTEGER NO NO
875
char_field VARCHAR YES YES
877
Field Type Null Default Default_is_NULL On_Update
878
unsigned_int_field INTEGER NO NO
879
char_field VARCHAR YES YES
880
ALTER TABLE t2 MODIFY unsigned_int_field BIGINT NOT NULL;
882
Field Type Null Default Default_is_NULL On_Update
883
unsigned_int_field BIGINT NO NO
884
char_field VARCHAR YES YES
886
CREATE TABLE t1 (f1 INT, f2 INT, f3 INT);
887
INSERT INTO t1 VALUES (1, 2, NULL);
891
ALTER TABLE t1 MODIFY COLUMN f3 INT AFTER f1;
895
ALTER TABLE t1 MODIFY COLUMN f3 INT AFTER f2;