8
8
col5 enum('PENDING', 'ACTIVE', 'DISABLED') not null,
9
9
col6 int not null, to_be_deleted int);
10
10
insert into t1 values (2,4,3,5,"PENDING",1,7);
12
col1 col2 col3 col4 col5 col6 to_be_deleted
15
12
add column col4_5 varchar(20) not null after col4,
16
13
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,
14
add column col8 datetime not null, drop column to_be_deleted,
26
15
change column col2 fourth varchar(30) not null after col3,
27
16
modify column col6 int not null first;
29
18
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
19
1 2 3 4 5 PENDING 0000-00-00 00:00:00
32
21
create table t1 (bandID INT NOT NULL PRIMARY KEY, payoutID int NOT NULL);
33
22
insert into t1 (bandID,payoutID) VALUES (1,6),(2,6),(3,4),(4,9),(5,10),(6,1),(7,12),(8,12);
89
78
ALTER TABLE t1 ORDER BY t1.id, t1.status, t1.type_id, t1.user_id, t1.body;
80
CREATE TABLE t1 (AnamneseId int NOT NULL auto_increment,B BLOB,PRIMARY KEY (AnamneseId)) engine=myisam;
81
insert into t1 values (null,"hello");
83
ALTER TABLE t1 ADD Column new_col int not null;
86
Table Op Msg_type Msg_text
87
test.t1 optimize status OK
91
89
create table t1 (i int not null auto_increment primary key);
92
90
insert into t1 values (null),(null),(null),(null);
93
91
alter table t1 drop i,add i int not null auto_increment, drop primary key, add primary key (i);
127
125
key (n4, n1, n2, n3) );
129
127
show keys from t1;
130
Table Unique Key_name Seq_in_index Column_name
128
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
129
t1 0 n1 1 n1 A 0 NULL NULL BTREE
130
t1 1 n1_2 1 n1 A 0 NULL NULL BTREE
131
t1 1 n1_2 2 n2 A 0 NULL NULL YES BTREE
132
t1 1 n1_2 3 n3 A 0 NULL NULL YES BTREE
133
t1 1 n1_2 4 n4 A 0 NULL NULL YES BTREE
134
t1 1 n2 1 n2 A 0 NULL NULL YES BTREE
135
t1 1 n2 2 n3 A 0 NULL NULL YES BTREE
136
t1 1 n2 3 n4 A 0 NULL NULL YES BTREE
137
t1 1 n2 4 n1 A 0 NULL NULL BTREE
138
t1 1 n3 1 n3 A 0 NULL NULL YES BTREE
139
t1 1 n3 2 n4 A 0 NULL NULL YES BTREE
140
t1 1 n3 3 n1 A 0 NULL NULL BTREE
141
t1 1 n3 4 n2 A 0 NULL NULL YES BTREE
142
t1 1 n4 1 n4 A 0 NULL NULL YES BTREE
143
t1 1 n4 2 n1 A 0 NULL NULL BTREE
144
t1 1 n4 3 n2 A 0 NULL NULL YES BTREE
145
t1 1 n4 4 n3 A 0 NULL NULL YES BTREE
148
146
set autocommit=0;
150
148
insert into t1 values(10,RAND()*1000,RAND()*1000,RAND());
164
162
Note 1031 Table storage engine for 't1' doesn't have this option
165
163
show keys from t1;
166
Table Unique Key_name Seq_in_index Column_name
164
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
165
t1 0 n1 1 n1 A 2 NULL NULL BTREE
166
t1 1 n1_2 1 n1 A 2 NULL NULL BTREE
167
t1 1 n1_2 2 n2 A 2 NULL NULL YES BTREE
168
t1 1 n1_2 3 n3 A 2 NULL NULL YES BTREE
169
t1 1 n1_2 4 n4 A 2 NULL NULL YES BTREE
170
t1 1 n2 1 n2 A 2 NULL NULL YES BTREE
171
t1 1 n2 2 n3 A 2 NULL NULL YES BTREE
172
t1 1 n2 3 n4 A 2 NULL NULL YES BTREE
173
t1 1 n2 4 n1 A 2 NULL NULL BTREE
174
t1 1 n3 1 n3 A 2 NULL NULL YES BTREE
175
t1 1 n3 2 n4 A 2 NULL NULL YES BTREE
176
t1 1 n3 3 n1 A 2 NULL NULL BTREE
177
t1 1 n3 4 n2 A 2 NULL NULL YES BTREE
178
t1 1 n4 1 n4 A 2 NULL NULL YES BTREE
179
t1 1 n4 2 n1 A 2 NULL NULL BTREE
180
t1 1 n4 3 n2 A 2 NULL NULL YES BTREE
181
t1 1 n4 4 n3 A 2 NULL NULL YES BTREE
185
183
create table t1 (i int not null auto_increment primary key);
186
184
alter table t1 rename t2;
187
185
alter table t2 rename t1, add c char(10) comment "no comment";
188
186
show columns from t1;
189
Field Type Null Default Default_is_NULL On_Update
187
Field Type Null Key Default Extra
188
i int NO PRI NULL auto_increment
189
c varchar(10) YES NULL
193
191
create table t1 (a int, b int);
194
192
set autocommit=0;
297
295
set autocommit=1;
298
296
alter table t1 add unique (a,b), add key (b);
299
297
show keys from t1;
300
Table Unique Key_name Seq_in_index Column_name
298
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
299
t1 0 a 1 a A 6 NULL NULL YES BTREE
300
t1 0 a 2 b A 300 NULL NULL YES BTREE
301
t1 1 b 1 b A 300 NULL NULL YES BTREE
304
302
analyze table t1;
305
303
Table Op Msg_type Msg_text
306
304
test.t1 analyze status OK
307
305
show keys from t1;
308
Table Unique Key_name Seq_in_index Column_name
306
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
307
t1 0 a 1 a A 6 NULL NULL YES BTREE
308
t1 0 a 2 b A 300 NULL NULL YES BTREE
309
t1 1 b 1 b A 300 NULL NULL YES BTREE
313
CREATE TEMPORARY TABLE t1 (
314
Host varchar(16) NOT NULL default '',
315
User varchar(16) NOT NULL default '',
312
Host varchar(16) binary NOT NULL default '',
313
User varchar(16) binary NOT NULL default '',
314
PRIMARY KEY (Host,User)
316
ALTER TABLE t1 DISABLE KEYS;
317
LOCK TABLES t1 WRITE;
318
INSERT INTO t1 VALUES ('localhost','root'),('localhost',''),('games','monty');
320
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
321
t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE
322
t1 0 PRIMARY 2 User A 0 NULL NULL BTREE
323
ALTER TABLE t1 ENABLE KEYS;
326
Table Op Msg_type Msg_text
327
test.t1 check status OK
330
Host varchar(16) binary NOT NULL default '',
331
User varchar(16) binary NOT NULL default '',
316
332
PRIMARY KEY (Host,User),
319
335
ALTER TABLE t1 DISABLE KEYS;
337
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
338
t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE
339
t1 0 PRIMARY 2 User A 0 NULL NULL BTREE
340
t1 1 Host 1 Host A NULL NULL NULL BTREE disabled
341
LOCK TABLES t1 WRITE;
320
342
INSERT INTO t1 VALUES ('localhost','root'),('localhost','');
344
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
345
t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE
346
t1 0 PRIMARY 2 User A 0 NULL NULL BTREE
347
t1 1 Host 1 Host A NULL NULL NULL BTREE disabled
321
348
ALTER TABLE t1 ENABLE KEYS;
350
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
351
t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE
352
t1 0 PRIMARY 2 User A 2 NULL NULL BTREE
353
t1 1 Host 1 Host A 1 NULL NULL BTREE
323
356
Table Op Msg_type Msg_text
324
357
test.t1 check status OK
358
LOCK TABLES t1 WRITE;
325
359
ALTER TABLE t1 RENAME t2;
326
361
select * from t2;
367
Host varchar(16) binary NOT NULL default '',
368
User varchar(16) binary NOT NULL default '',
369
PRIMARY KEY (Host,User),
372
LOCK TABLES t1 WRITE;
373
ALTER TABLE t1 DISABLE KEYS;
375
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
376
t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE
377
t1 0 PRIMARY 2 User A 0 NULL NULL BTREE
378
t1 1 Host 1 Host A NULL NULL NULL BTREE disabled
331
380
create table t1 (a int);
332
381
alter table t1 rename to ``;
333
382
ERROR 42000: Incorrect table name ''
337
386
drop table if exists t1;
339
388
Note 1051 Unknown table 't1'
340
create TEMPORARY table t1 ( a varchar(10) not null primary key ) engine=myisam;
389
create table t1 ( a varchar(10) not null primary key ) engine=myisam;
342
391
alter table t1 modify a varchar(10);
344
393
alter table t1 modify a varchar(10) not null;
345
394
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);
395
create 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;
396
insert into t1 (a) values(1);
348
397
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 # # # # #
398
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
399
t1 MyISAM X Fixed 1 37 X X X X X X X X utf8_general_ci NULL
351
400
alter table t1 modify a int;
352
401
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 # # # # #
402
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
403
t1 MyISAM X Fixed 1 37 X X X X X X X X utf8_general_ci NULL
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;
405
create 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
406
insert into t1 (a) values(1);
358
407
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 # # # # #
408
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
409
t1 MyISAM X Fixed 1 37 X X X X X X X X utf8_general_ci NULL
362
411
CREATE TABLE t1 (a int PRIMARY KEY, b INT UNIQUE);
363
412
ALTER TABLE t1 DROP PRIMARY KEY;
364
413
SHOW CREATE TABLE t1;
365
414
Table Create Table
366
415
t1 CREATE TABLE `t1` (
368
`b` INT DEFAULT NULL,
417
`b` int DEFAULT NULL,
369
418
UNIQUE KEY `b` (`b`)
370
) ENGINE=DEFAULT COLLATE = utf8_general_ci
371
420
ALTER TABLE t1 DROP PRIMARY KEY;
372
421
ERROR 42000: Can't DROP 'PRIMARY'; check that column/key exists
388
437
drop table if exists t1;
389
438
create table t1 (a int, key(a));
390
439
show indexes from t1;
391
Table Unique Key_name Seq_in_index Column_name
440
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
441
t1 1 a 1 a A 0 NULL NULL YES BTREE
393
442
"this used not to disable the index"
394
443
alter table t1 modify a int;
395
444
show indexes from t1;
396
Table Unique Key_name Seq_in_index Column_name
445
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
446
t1 1 a 1 a A 0 NULL NULL YES BTREE
398
447
alter table t1 enable keys;
400
449
Note 1031 Table storage engine for 't1' doesn't have this option
401
450
show indexes from t1;
402
Table Unique Key_name Seq_in_index Column_name
451
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
452
t1 1 a 1 a A 0 NULL NULL YES BTREE
404
453
alter table t1 modify a bigint;
405
454
show indexes from t1;
406
Table Unique Key_name Seq_in_index Column_name
455
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
456
t1 1 a 1 a A 0 NULL NULL YES BTREE
408
457
alter table t1 enable keys;
410
459
Note 1031 Table storage engine for 't1' doesn't have this option
411
460
show indexes from t1;
412
Table Unique Key_name Seq_in_index Column_name
461
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
462
t1 1 a 1 a A 0 NULL NULL YES BTREE
414
463
alter table t1 add b char(10);
415
464
show indexes from t1;
416
Table Unique Key_name Seq_in_index Column_name
465
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
466
t1 1 a 1 a A 0 NULL NULL YES BTREE
418
467
alter table t1 add c decimal(10,2);
419
468
show indexes from t1;
420
Table Unique Key_name Seq_in_index Column_name
469
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
470
t1 1 a 1 a A 0 NULL NULL YES BTREE
422
471
"this however did"
424
473
show indexes from t1;
425
Table Unique Key_name Seq_in_index Column_name
474
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
475
t1 1 a 1 a A 0 NULL NULL YES BTREE
428
Field Type Null Default Default_is_NULL On_Update
477
Field Type Null Key Default Extra
478
a bigint YES MUL NULL
479
b varchar(10) YES NULL
480
c decimal(10,2) YES NULL
432
481
alter table t1 add d decimal(15,5);
433
482
"The key should still be disabled"
434
483
show indexes from t1;
435
Table Unique Key_name Seq_in_index Column_name
484
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
485
t1 1 a 1 a A 0 NULL NULL YES BTREE
438
487
"Now will test with one unique index"
439
488
create table t1(a int, b char(10), unique(a));
440
489
show indexes from t1;
441
Table Unique Key_name Seq_in_index Column_name
490
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
491
t1 0 a 1 a A 0 NULL NULL YES BTREE
444
493
show indexes from t1;
445
Table Unique Key_name Seq_in_index Column_name
494
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
495
t1 0 a 1 a A 0 NULL NULL YES BTREE
447
496
alter table t1 enable keys;
449
498
Note 1031 Table storage engine for 't1' doesn't have this option
451
500
"Unique index, no change"
452
501
alter table t1 modify a int;
453
502
show indexes from t1;
454
Table Unique Key_name Seq_in_index Column_name
503
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
504
t1 0 a 1 a A 0 NULL NULL YES BTREE
456
505
"Change the type implying data copy"
457
506
"Unique index, no change"
458
507
alter table t1 modify a bigint;
459
508
show indexes from t1;
460
Table Unique Key_name Seq_in_index Column_name
509
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
510
t1 0 a 1 a A 0 NULL NULL YES BTREE
462
511
alter table t1 modify a bigint;
463
512
show indexes from t1;
464
Table Unique Key_name Seq_in_index Column_name
513
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
514
t1 0 a 1 a A 0 NULL NULL YES BTREE
466
515
alter table t1 modify a int;
467
516
show indexes from t1;
468
Table Unique Key_name Seq_in_index Column_name
517
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
518
t1 0 a 1 a A 0 NULL NULL YES BTREE
471
520
"Now will test with one unique and one non-unique index"
472
521
create table t1(a int, b char(10), unique(a), key(b));
473
522
show indexes from t1;
474
Table Unique Key_name Seq_in_index Column_name
523
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
524
t1 0 a 1 a A 0 NULL NULL YES BTREE
525
t1 1 b 1 b A 0 NULL NULL YES BTREE
478
527
show indexes from t1;
479
Table Unique Key_name Seq_in_index Column_name
528
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
529
t1 0 a 1 a A 0 NULL NULL YES BTREE
530
t1 1 b 1 b A 0 NULL NULL YES BTREE
482
531
alter table t1 enable keys;
484
533
Note 1031 Table storage engine for 't1' doesn't have this option
486
535
"The non-unique index will be disabled"
487
536
alter table t1 modify a int;
488
537
show indexes from t1;
489
Table Unique Key_name Seq_in_index Column_name
538
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
539
t1 0 a 1 a A 0 NULL NULL YES BTREE
540
t1 1 b 1 b A 0 NULL NULL YES BTREE
492
541
alter table t1 enable keys;
494
543
Note 1031 Table storage engine for 't1' doesn't have this option
495
544
show indexes from t1;
496
Table Unique Key_name Seq_in_index Column_name
545
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
546
t1 0 a 1 a A 0 NULL NULL YES BTREE
547
t1 1 b 1 b A 0 NULL NULL YES BTREE
499
548
"Change the type implying data copy"
500
549
"The non-unique index will be disabled"
501
550
alter table t1 modify a bigint;
502
551
show indexes from t1;
503
Table Unique Key_name Seq_in_index Column_name
552
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
553
t1 0 a 1 a A 0 NULL NULL YES BTREE
554
t1 1 b 1 b A 0 NULL NULL YES BTREE
506
555
"Change again the type, but leave the indexes as_is"
507
556
alter table t1 modify a int;
508
557
show indexes from t1;
509
Table Unique Key_name Seq_in_index Column_name
558
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
559
t1 0 a 1 a A 0 NULL NULL YES BTREE
560
t1 1 b 1 b A 0 NULL NULL YES BTREE
512
561
"Try the same. When data is no copied on similar tables, this is noop"
513
562
alter table t1 modify a int;
514
563
show indexes from t1;
515
Table Unique Key_name Seq_in_index Column_name
564
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
565
t1 0 a 1 a A 0 NULL NULL YES BTREE
566
t1 1 b 1 b A 0 NULL NULL YES BTREE
519
568
create database mysqltest;
520
569
create table t1 (c1 int);
528
577
drop database mysqltest;
529
578
alter table test.t1 rename t1;
530
ERROR 3D000: No schema selected
579
ERROR 3D000: No database selected
531
580
alter table test.t1 rename test.t1;
534
CREATE TABLE t1(a INT) ROW_FORMAT=COMPACT;
583
CREATE TABLE t1(a INT) ROW_FORMAT=FIXED;
585
Warning 1478 InnoDB: assuming ROW_FORMAT=COMPACT.
535
586
CREATE INDEX i1 ON t1(a);
536
587
SHOW CREATE TABLE t1;
537
588
Table Create Table
538
589
t1 CREATE TABLE `t1` (
539
`a` INT DEFAULT NULL,
590
`a` int DEFAULT NULL,
541
) ENGINE=DEFAULT ROW_FORMAT='COMPACT' COLLATE = utf8_general_ci
592
) ENGINE=InnoDB ROW_FORMAT=FIXED
542
593
DROP INDEX i1 ON t1;
543
594
SHOW CREATE TABLE t1;
544
595
Table Create Table
545
596
t1 CREATE TABLE `t1` (
547
) ENGINE=DEFAULT ROW_FORMAT='COMPACT' COLLATE = utf8_general_ci
598
) ENGINE=InnoDB ROW_FORMAT=FIXED
549
600
DROP TABLE IF EXISTS bug24219;
550
601
DROP TABLE IF EXISTS bug24219_2;
551
602
CREATE TABLE bug24219 (a INT, INDEX(a));
552
603
SHOW INDEX FROM bug24219;
553
Table Unique Key_name Seq_in_index Column_name
604
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
605
bug24219 1 a 1 a A 0 NULL NULL YES BTREE
555
606
ALTER TABLE bug24219 RENAME TO bug24219_2, DISABLE KEYS;
557
608
Note 1031 Table storage engine for 'bug24219' doesn't have this option
558
609
SHOW INDEX FROM bug24219_2;
559
Table Unique Key_name Seq_in_index Column_name
610
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
611
bug24219_2 1 a 1 a A 0 NULL NULL YES BTREE
561
612
DROP TABLE bug24219_2;
562
613
drop table if exists table_24562;
563
614
create table table_24562(
849
drop table if exists t1, t2, t3;
850
create table t1 (i int);
851
create table t3 (j int);
852
insert into t1 values ();
853
insert into t3 values ();
854
lock table t1 write, t3 read;
855
alter table t1 modify i int default 1;
856
insert into t1 values ();
861
alter table t1 change i c char(10) default "Two";
862
insert into t1 values ();
868
alter table t1 modify c char(10) default "Three", rename to t2;
870
ERROR HY000: Table 't1' was not locked with LOCK TABLES
872
ERROR HY000: Table 't2' was not locked with LOCK TABLES
877
insert into t2 values ();
884
lock table t2 write, t3 read;
885
alter table t2 change c vc varchar(100) default "Four", rename to t1;
887
ERROR HY000: Table 't1' was not locked with LOCK TABLES
889
ERROR HY000: Table 't2' was not locked with LOCK TABLES
894
insert into t1 values ();
798
903
DROP TABLE IF EXISTS `t+1`, `t+2`;
799
904
CREATE TABLE `t+1` (c1 INT);
800
905
ALTER TABLE `t+1` RENAME `t+2`;
801
906
CREATE TABLE `t+1` (c1 INT);
802
907
ALTER TABLE `t+1` RENAME `t+2`;
803
ERROR 42S01: Table 'test.t+2' already exists
908
ERROR 42S01: Table 't+2' already exists
804
909
DROP TABLE `t+1`, `t+2`;
805
910
CREATE TEMPORARY TABLE `tt+1` (c1 INT);
806
911
ALTER TABLE `tt+1` RENAME `tt+2`;
807
912
CREATE TEMPORARY TABLE `tt+1` (c1 INT);
808
913
ALTER TABLE `tt+1` RENAME `tt+2`;
809
ERROR 42S01: Table 'test.#tt+2' already exists
914
ERROR 42S01: Table 'tt+2' already exists
810
915
SHOW CREATE TABLE `tt+1`;
811
916
Table Create Table
812
917
tt+1 CREATE TEMPORARY TABLE `tt+1` (
813
`c1` INT DEFAULT NULL
814
) ENGINE=DEFAULT COLLATE = utf8_general_ci
918
`c1` int DEFAULT NULL
815
920
SHOW CREATE TABLE `tt+2`;
816
921
Table Create Table
817
922
tt+2 CREATE TEMPORARY TABLE `tt+2` (
818
`c1` INT DEFAULT NULL
819
) ENGINE=DEFAULT COLLATE = utf8_general_ci
923
`c1` int DEFAULT NULL
820
925
DROP TABLE `tt+1`, `tt+2`;
821
926
CREATE TEMPORARY TABLE `#sql1` (c1 INT);
822
927
CREATE TEMPORARY TABLE `@0023sql2` (c1 INT);
827
930
ALTER TABLE `#sql1` RENAME `@0023sql1`;
828
931
ALTER TABLE `@0023sql2` RENAME `#sql2`;
833
934
INSERT INTO `#sql2` VALUES (1);
834
935
INSERT INTO `@0023sql1` VALUES (2);
835
936
SHOW CREATE TABLE `#sql2`;
836
937
Table Create Table
837
938
#sql2 CREATE TEMPORARY TABLE `#sql2` (
838
`c1` INT DEFAULT NULL
839
) ENGINE=DEFAULT COLLATE = utf8_general_ci
939
`c1` int DEFAULT NULL
840
941
SHOW CREATE TABLE `@0023sql1`;
841
942
Table Create Table
842
943
@0023sql1 CREATE TEMPORARY TABLE `@0023sql1` (
843
`c1` INT DEFAULT NULL
844
) ENGINE=DEFAULT COLLATE = utf8_general_ci
944
`c1` int DEFAULT NULL
845
946
DROP TABLE `#sql2`, `@0023sql1`;
846
947
DROP TABLE IF EXISTS t1;
847
948
DROP TABLE IF EXISTS t2;
851
952
INDEX(`int_field`)
854
Field Type Null Default Default_is_NULL On_Update
855
int_field INTEGER NO NO
856
char_field VARCHAR YES YES
955
Field Type Null Key Default Extra
956
int_field int NO MUL NULL
957
char_field varchar(10) YES NULL
857
958
SHOW INDEXES FROM t1;
858
Table Unique Key_name Seq_in_index Column_name
859
t1 NO int_field 1 int_field
959
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
960
t1 1 int_field 1 int_field A 0 NULL NULL BTREE
860
961
INSERT INTO t1 VALUES (1, "edno"), (1, "edno"), (2, "dve"), (3, "tri"), (5, "pet");
861
962
"Non-copy data change - new frm, but old data and index files"
862
963
ALTER TABLE t1 CHANGE int_field unsigned_int_field INTEGER NOT NULL, RENAME t2;
863
964
SELECT * FROM t1 ORDER BY int_field;
864
ERROR 42S02: Unknown table 'test.t1'
965
ERROR 42S02: Table 'test.t1' doesn't exist
865
966
SELECT * FROM t2 ORDER BY unsigned_int_field;
866
967
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
974
Field Type Null Key Default Extra
975
unsigned_int_field int NO MUL NULL
976
char_field varchar(10) YES NULL
877
Field Type Null Default Default_is_NULL On_Update
878
unsigned_int_field INTEGER NO NO
879
char_field VARCHAR YES YES
978
Field Type Null Key Default Extra
979
unsigned_int_field int NO MUL NULL
980
char_field varchar(10) YES NULL
880
981
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
983
Field Type Null Key Default Extra
984
unsigned_int_field bigint NO MUL NULL
985
char_field varchar(10) YES NULL
886
987
CREATE TABLE t1 (f1 INT, f2 INT, f3 INT);
887
988
INSERT INTO t1 VALUES (1, 2, NULL);