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);
61
50
PRIMARY KEY (GROUP_ID,LANG_ID),
63
52
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
53
SHOW FULL COLUMNS FROM t1;
54
Field Type Collation Null Key Default Extra Privileges Comment
55
GROUP_ID int NULL NO PRI 0 #
56
LANG_ID int NULL NO PRI 0 #
57
NAME varchar(80) utf8_general_ci NO MUL NULL #
70
59
create table t1 (n int);
71
60
insert into t1 values(9),(3),(12),(10);
127
116
key (n4, n1, n2, n3) );
129
118
show keys from t1;
130
Table Unique Key_name Seq_in_index Column_name
119
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
120
t1 0 n1 1 n1 A 0 NULL NULL BTREE
121
t1 1 n1_2 1 n1 A 0 NULL NULL BTREE
122
t1 1 n1_2 2 n2 A 0 NULL NULL YES BTREE
123
t1 1 n1_2 3 n3 A 0 NULL NULL YES BTREE
124
t1 1 n1_2 4 n4 A 0 NULL NULL YES BTREE
125
t1 1 n2 1 n2 A 0 NULL NULL YES BTREE
126
t1 1 n2 2 n3 A 0 NULL NULL YES BTREE
127
t1 1 n2 3 n4 A 0 NULL NULL YES BTREE
128
t1 1 n2 4 n1 A 0 NULL NULL BTREE
129
t1 1 n3 1 n3 A 0 NULL NULL YES BTREE
130
t1 1 n3 2 n4 A 0 NULL NULL YES BTREE
131
t1 1 n3 3 n1 A 0 NULL NULL BTREE
132
t1 1 n3 4 n2 A 0 NULL NULL YES BTREE
133
t1 1 n4 1 n4 A 0 NULL NULL YES BTREE
134
t1 1 n4 2 n1 A 0 NULL NULL BTREE
135
t1 1 n4 3 n2 A 0 NULL NULL YES BTREE
136
t1 1 n4 4 n3 A 0 NULL NULL YES BTREE
148
137
set autocommit=0;
150
139
insert into t1 values(10,RAND()*1000,RAND()*1000,RAND());
164
153
Note 1031 Table storage engine for 't1' doesn't have this option
165
154
show keys from t1;
166
Table Unique Key_name Seq_in_index Column_name
155
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
156
t1 0 n1 1 n1 A 2 NULL NULL BTREE
157
t1 1 n1_2 1 n1 A 2 NULL NULL BTREE
158
t1 1 n1_2 2 n2 A 2 NULL NULL YES BTREE
159
t1 1 n1_2 3 n3 A 2 NULL NULL YES BTREE
160
t1 1 n1_2 4 n4 A 2 NULL NULL YES BTREE
161
t1 1 n2 1 n2 A 2 NULL NULL YES BTREE
162
t1 1 n2 2 n3 A 2 NULL NULL YES BTREE
163
t1 1 n2 3 n4 A 2 NULL NULL YES BTREE
164
t1 1 n2 4 n1 A 2 NULL NULL BTREE
165
t1 1 n3 1 n3 A 2 NULL NULL YES BTREE
166
t1 1 n3 2 n4 A 2 NULL NULL YES BTREE
167
t1 1 n3 3 n1 A 2 NULL NULL BTREE
168
t1 1 n3 4 n2 A 2 NULL NULL YES BTREE
169
t1 1 n4 1 n4 A 2 NULL NULL YES BTREE
170
t1 1 n4 2 n1 A 2 NULL NULL BTREE
171
t1 1 n4 3 n2 A 2 NULL NULL YES BTREE
172
t1 1 n4 4 n3 A 2 NULL NULL YES BTREE
185
174
create table t1 (i int not null auto_increment primary key);
186
175
alter table t1 rename t2;
187
176
alter table t2 rename t1, add c char(10) comment "no comment";
188
177
show columns from t1;
189
Field Type Null Default Default_is_NULL On_Update
178
Field Type Null Key Default Extra
179
i int NO PRI NULL auto_increment
180
c varchar(10) YES NULL
193
182
create table t1 (a int, b int);
194
183
set autocommit=0;
297
286
set autocommit=1;
298
287
alter table t1 add unique (a,b), add key (b);
299
288
show keys from t1;
300
Table Unique Key_name Seq_in_index Column_name
289
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
290
t1 0 a 1 a A 6 NULL NULL YES BTREE
291
t1 0 a 2 b A 300 NULL NULL YES BTREE
292
t1 1 b 1 b A 300 NULL NULL YES BTREE
304
293
analyze table t1;
305
294
Table Op Msg_type Msg_text
306
295
test.t1 analyze status OK
307
296
show keys from t1;
308
Table Unique Key_name Seq_in_index Column_name
297
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
298
t1 0 a 1 a A 6 NULL NULL YES BTREE
299
t1 0 a 2 b A 300 NULL NULL YES BTREE
300
t1 1 b 1 b A 300 NULL NULL YES BTREE
313
302
CREATE TEMPORARY TABLE t1 (
314
Host varchar(16) NOT NULL default '',
315
User varchar(16) NOT NULL default '',
303
Host varchar(16) binary NOT NULL default '',
304
User varchar(16) binary NOT NULL default '',
316
305
PRIMARY KEY (Host,User),
319
308
ALTER TABLE t1 DISABLE KEYS;
310
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
311
t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE
312
t1 0 PRIMARY 2 User A 0 NULL NULL BTREE
313
t1 1 Host 1 Host A NULL NULL NULL BTREE disabled
320
314
INSERT INTO t1 VALUES ('localhost','root'),('localhost','');
316
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
317
t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE
318
t1 0 PRIMARY 2 User A 2 NULL NULL BTREE
319
t1 1 Host 1 Host A NULL NULL NULL BTREE disabled
321
320
ALTER TABLE t1 ENABLE KEYS;
322
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
323
t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE
324
t1 0 PRIMARY 2 User A 2 NULL NULL BTREE
325
t1 1 Host 1 Host A NULL NULL NULL BTREE
323
327
Table Op Msg_type Msg_text
324
328
test.t1 check status OK
346
350
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
351
insert into t1 (a,b,c,d,e,f,g,h,i) values(1,1,1,1,1,1,1,1,1);
348
352
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 # # # # #
353
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
351
354
alter table t1 modify a int;
352
355
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
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
356
358
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
359
insert into t1 (a) values(1);
358
360
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 # # # # #
361
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
362
363
CREATE TABLE t1 (a int PRIMARY KEY, b INT UNIQUE);
363
364
ALTER TABLE t1 DROP PRIMARY KEY;
364
365
SHOW CREATE TABLE t1;
365
366
Table Create Table
366
367
t1 CREATE TABLE `t1` (
368
`b` INT DEFAULT NULL,
369
`b` int DEFAULT NULL,
369
370
UNIQUE KEY `b` (`b`)
370
) ENGINE=DEFAULT COLLATE = utf8_general_ci
371
372
ALTER TABLE t1 DROP PRIMARY KEY;
372
373
ERROR 42000: Can't DROP 'PRIMARY'; check that column/key exists
388
389
drop table if exists t1;
389
390
create table t1 (a int, key(a));
390
391
show indexes from t1;
391
Table Unique Key_name Seq_in_index Column_name
392
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
393
t1 1 a 1 a A 0 NULL NULL YES BTREE
393
394
"this used not to disable the index"
394
395
alter table t1 modify a int;
395
396
show indexes from t1;
396
Table Unique Key_name Seq_in_index Column_name
397
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
398
t1 1 a 1 a A 0 NULL NULL YES BTREE
398
399
alter table t1 enable keys;
400
401
Note 1031 Table storage engine for 't1' doesn't have this option
401
402
show indexes from t1;
402
Table Unique Key_name Seq_in_index Column_name
403
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
404
t1 1 a 1 a A 0 NULL NULL YES BTREE
404
405
alter table t1 modify a bigint;
405
406
show indexes from t1;
406
Table Unique Key_name Seq_in_index Column_name
407
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
408
t1 1 a 1 a A 0 NULL NULL YES BTREE
408
409
alter table t1 enable keys;
410
411
Note 1031 Table storage engine for 't1' doesn't have this option
411
412
show indexes from t1;
412
Table Unique Key_name Seq_in_index Column_name
413
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
414
t1 1 a 1 a A 0 NULL NULL YES BTREE
414
415
alter table t1 add b char(10);
415
416
show indexes from t1;
416
Table Unique Key_name Seq_in_index Column_name
417
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
418
t1 1 a 1 a A 0 NULL NULL YES BTREE
418
419
alter table t1 add c decimal(10,2);
419
420
show indexes from t1;
420
Table Unique Key_name Seq_in_index Column_name
421
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
422
t1 1 a 1 a A 0 NULL NULL YES BTREE
422
423
"this however did"
424
425
show indexes from t1;
425
Table Unique Key_name Seq_in_index Column_name
426
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
427
t1 1 a 1 a A 0 NULL NULL YES BTREE
428
Field Type Null Default Default_is_NULL On_Update
429
Field Type Null Key Default Extra
430
a bigint YES MUL NULL
431
b varchar(10) YES NULL
432
c decimal(10,2) YES NULL
432
433
alter table t1 add d decimal(15,5);
433
434
"The key should still be disabled"
434
435
show indexes from t1;
435
Table Unique Key_name Seq_in_index Column_name
436
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
437
t1 1 a 1 a A 0 NULL NULL YES BTREE
438
439
"Now will test with one unique index"
439
440
create table t1(a int, b char(10), unique(a));
440
441
show indexes from t1;
441
Table Unique Key_name Seq_in_index Column_name
442
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
443
t1 0 a 1 a A 0 NULL NULL YES BTREE
444
445
show indexes from t1;
445
Table Unique Key_name Seq_in_index Column_name
446
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
447
t1 0 a 1 a A 0 NULL NULL YES BTREE
447
448
alter table t1 enable keys;
449
450
Note 1031 Table storage engine for 't1' doesn't have this option
451
452
"Unique index, no change"
452
453
alter table t1 modify a int;
453
454
show indexes from t1;
454
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 0 a 1 a A 0 NULL NULL YES BTREE
456
457
"Change the type implying data copy"
457
458
"Unique index, no change"
458
459
alter table t1 modify a bigint;
459
460
show indexes from t1;
460
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 0 a 1 a A 0 NULL NULL YES BTREE
462
463
alter table t1 modify a bigint;
463
464
show indexes from t1;
464
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 0 a 1 a A 0 NULL NULL YES BTREE
466
467
alter table t1 modify a int;
467
468
show indexes from t1;
468
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 0 a 1 a A 0 NULL NULL YES BTREE
471
472
"Now will test with one unique and one non-unique index"
472
473
create table t1(a int, b char(10), unique(a), key(b));
473
474
show indexes from t1;
474
Table Unique Key_name Seq_in_index Column_name
475
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
476
t1 0 a 1 a A 0 NULL NULL YES BTREE
477
t1 1 b 1 b A 0 NULL NULL YES BTREE
478
479
show indexes from t1;
479
Table Unique Key_name Seq_in_index Column_name
480
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
481
t1 0 a 1 a A 0 NULL NULL YES BTREE
482
t1 1 b 1 b A 0 NULL NULL YES BTREE
482
483
alter table t1 enable keys;
484
485
Note 1031 Table storage engine for 't1' doesn't have this option
486
487
"The non-unique index will be disabled"
487
488
alter table t1 modify a int;
488
489
show indexes from t1;
489
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
492
t1 1 b 1 b A 0 NULL NULL YES BTREE
492
493
alter table t1 enable keys;
494
495
Note 1031 Table storage engine for 't1' doesn't have this option
495
496
show indexes from t1;
496
Table Unique Key_name Seq_in_index Column_name
497
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
498
t1 0 a 1 a A 0 NULL NULL YES BTREE
499
t1 1 b 1 b A 0 NULL NULL YES BTREE
499
500
"Change the type implying data copy"
500
501
"The non-unique index will be disabled"
501
502
alter table t1 modify a bigint;
502
503
show indexes from t1;
503
Table Unique Key_name Seq_in_index Column_name
504
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
505
t1 0 a 1 a A 0 NULL NULL YES BTREE
506
t1 1 b 1 b A 0 NULL NULL YES BTREE
506
507
"Change again the type, but leave the indexes as_is"
507
508
alter table t1 modify a int;
508
509
show indexes from t1;
509
Table Unique Key_name Seq_in_index Column_name
510
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
511
t1 0 a 1 a A 0 NULL NULL YES BTREE
512
t1 1 b 1 b A 0 NULL NULL YES BTREE
512
513
"Try the same. When data is no copied on similar tables, this is noop"
513
514
alter table t1 modify a int;
514
515
show indexes from t1;
515
Table Unique Key_name Seq_in_index Column_name
516
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
517
t1 0 a 1 a A 0 NULL NULL YES BTREE
518
t1 1 b 1 b A 0 NULL NULL YES BTREE
519
520
create database mysqltest;
520
521
create table t1 (c1 int);
528
529
drop database mysqltest;
529
530
alter table test.t1 rename t1;
530
ERROR 3D000: No schema selected
531
ERROR 3D000: No database selected
531
532
alter table test.t1 rename test.t1;
534
CREATE TABLE t1(a INT) ROW_FORMAT=COMPACT;
535
CREATE TABLE t1(a INT) ROW_FORMAT=FIXED;
537
Warning 1478 InnoDB: assuming ROW_FORMAT=COMPACT.
535
538
CREATE INDEX i1 ON t1(a);
536
539
SHOW CREATE TABLE t1;
537
540
Table Create Table
538
541
t1 CREATE TABLE `t1` (
539
`a` INT DEFAULT NULL,
542
`a` int DEFAULT NULL,
541
) ENGINE=DEFAULT ROW_FORMAT='COMPACT' COLLATE = utf8_general_ci
544
) ENGINE=DEFAULT ROW_FORMAT=FIXED
542
545
DROP INDEX i1 ON t1;
543
546
SHOW CREATE TABLE t1;
544
547
Table Create Table
545
548
t1 CREATE TABLE `t1` (
547
) ENGINE=DEFAULT ROW_FORMAT='COMPACT' COLLATE = utf8_general_ci
550
) ENGINE=DEFAULT ROW_FORMAT=FIXED
549
552
DROP TABLE IF EXISTS bug24219;
550
553
DROP TABLE IF EXISTS bug24219_2;
551
554
CREATE TABLE bug24219 (a INT, INDEX(a));
552
555
SHOW INDEX FROM bug24219;
553
Table Unique Key_name Seq_in_index Column_name
556
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
557
bug24219 1 a 1 a A 0 NULL NULL YES BTREE
555
558
ALTER TABLE bug24219 RENAME TO bug24219_2, DISABLE KEYS;
557
560
Note 1031 Table storage engine for 'bug24219' doesn't have this option
558
561
SHOW INDEX FROM bug24219_2;
559
Table Unique Key_name Seq_in_index Column_name
562
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
563
bug24219_2 1 a 1 a A 0 NULL NULL YES BTREE
561
564
DROP TABLE bug24219_2;
562
565
drop table if exists table_24562;
563
566
create table table_24562(
673
676
create table t1 (mycol int not null);
674
677
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
Field Type Null Key Default Extra
679
create TEMPORARY table t1(id int primary key auto_increment) engine=MEMORY;
682
create TEMPORARY table t1(id int primary key auto_increment) engine=heap;
680
683
insert into t1 values (null);
681
684
insert into t1 values (null);
682
685
select * from t1;
758
761
create TEMPORARY table t1 (t varchar(255) default null, key t (t(80))) engine=myisam;
759
762
alter table t1 change t t text;
761
CREATE TABLE t1 (s CHAR(8));
764
CREATE TABLE t1 (s CHAR(8) BINARY);
762
765
INSERT INTO t1 VALUES ('test');
763
766
SELECT LENGTH(s) FROM t1;
766
ALTER TABLE t1 MODIFY s CHAR(10);
769
ALTER TABLE t1 MODIFY s CHAR(10) BINARY;
767
770
SELECT LENGTH(s) FROM t1;
800
803
ALTER TABLE `t+1` RENAME `t+2`;
801
804
CREATE TABLE `t+1` (c1 INT);
802
805
ALTER TABLE `t+1` RENAME `t+2`;
803
ERROR 42S01: Table 'test.t+2' already exists
806
ERROR 42S01: Table 't+2' already exists
804
807
DROP TABLE `t+1`, `t+2`;
805
808
CREATE TEMPORARY TABLE `tt+1` (c1 INT);
806
809
ALTER TABLE `tt+1` RENAME `tt+2`;
807
810
CREATE TEMPORARY TABLE `tt+1` (c1 INT);
808
811
ALTER TABLE `tt+1` RENAME `tt+2`;
809
ERROR 42S01: Table 'test.#tt+2' already exists
812
ERROR 42S01: Table 'tt+2' already exists
810
813
SHOW CREATE TABLE `tt+1`;
811
814
Table Create Table
812
815
tt+1 CREATE TEMPORARY TABLE `tt+1` (
813
`c1` INT DEFAULT NULL
814
) ENGINE=DEFAULT COLLATE = utf8_general_ci
816
`c1` int DEFAULT NULL
815
818
SHOW CREATE TABLE `tt+2`;
816
819
Table Create Table
817
820
tt+2 CREATE TEMPORARY TABLE `tt+2` (
818
`c1` INT DEFAULT NULL
819
) ENGINE=DEFAULT COLLATE = utf8_general_ci
821
`c1` int DEFAULT NULL
820
823
DROP TABLE `tt+1`, `tt+2`;
821
824
CREATE TEMPORARY TABLE `#sql1` (c1 INT);
822
825
CREATE TEMPORARY TABLE `@0023sql2` (c1 INT);
827
828
ALTER TABLE `#sql1` RENAME `@0023sql1`;
828
829
ALTER TABLE `@0023sql2` RENAME `#sql2`;
833
832
INSERT INTO `#sql2` VALUES (1);
834
833
INSERT INTO `@0023sql1` VALUES (2);
835
834
SHOW CREATE TABLE `#sql2`;
836
835
Table Create Table
837
836
#sql2 CREATE TEMPORARY TABLE `#sql2` (
838
`c1` INT DEFAULT NULL
839
) ENGINE=DEFAULT COLLATE = utf8_general_ci
837
`c1` int DEFAULT NULL
840
839
SHOW CREATE TABLE `@0023sql1`;
841
840
Table Create Table
842
841
@0023sql1 CREATE TEMPORARY TABLE `@0023sql1` (
843
`c1` INT DEFAULT NULL
844
) ENGINE=DEFAULT COLLATE = utf8_general_ci
842
`c1` int DEFAULT NULL
845
844
DROP TABLE `#sql2`, `@0023sql1`;
846
845
DROP TABLE IF EXISTS t1;
847
846
DROP TABLE IF EXISTS t2;
851
850
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
853
Field Type Null Key Default Extra
854
int_field int NO MUL NULL
855
char_field varchar(10) YES NULL
857
856
SHOW INDEXES FROM t1;
858
Table Unique Key_name Seq_in_index Column_name
859
t1 NO int_field 1 int_field
857
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
858
t1 1 int_field 1 int_field A 0 NULL NULL BTREE
860
859
INSERT INTO t1 VALUES (1, "edno"), (1, "edno"), (2, "dve"), (3, "tri"), (5, "pet");
861
860
"Non-copy data change - new frm, but old data and index files"
862
861
ALTER TABLE t1 CHANGE int_field unsigned_int_field INTEGER NOT NULL, RENAME t2;
863
862
SELECT * FROM t1 ORDER BY int_field;
864
ERROR 42S02: Unknown table 'test.t1'
863
ERROR 42S02: Table 'test.t1' doesn't exist
865
864
SELECT * FROM t2 ORDER BY unsigned_int_field;
866
865
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
872
Field Type Null Key Default Extra
873
unsigned_int_field int NO MUL NULL
874
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
876
Field Type Null Key Default Extra
877
unsigned_int_field int NO MUL NULL
878
char_field varchar(10) YES NULL
880
879
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
881
Field Type Null Key Default Extra
882
unsigned_int_field bigint NO MUL NULL
883
char_field varchar(10) YES NULL
886
885
CREATE TABLE t1 (f1 INT, f2 INT, f3 INT);
887
886
INSERT INTO t1 VALUES (1, 2, NULL);