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);
63
52
ALTER TABLE t1 CHANGE NAME NAME CHAR(80) not null;
64
53
show COLUMNS FROM t1;
65
54
Field Type Null Default Default_is_NULL On_Update
66
GROUP_ID INTEGER NO 0 NO
67
LANG_ID INTEGER NO 0 NO
55
GROUP_ID INTEGER FALSE 0 FALSE
56
LANG_ID INTEGER FALSE 0 FALSE
57
NAME VARCHAR FALSE FALSE
70
59
create table t1 (n int);
71
60
insert into t1 values(9),(3),(12),(10);
164
153
Note 1031 Table storage engine for 't1' doesn't have this option
165
154
show keys from t1;
166
155
Table Unique Key_name Seq_in_index Column_name
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
178
Field Type Null Default Default_is_NULL On_Update
179
i INTEGER FALSE 0 FALSE
193
182
create table t1 (a int, b int);
194
183
set autocommit=0;
298
287
alter table t1 add unique (a,b), add key (b);
299
288
show keys from t1;
300
289
Table Unique Key_name Seq_in_index Column_name
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
297
Table Unique Key_name Seq_in_index Column_name
313
302
CREATE TEMPORARY TABLE t1 (
314
303
Host varchar(16) NOT NULL default '',
389
378
create table t1 (a int, key(a));
390
379
show indexes from t1;
391
380
Table Unique Key_name Seq_in_index Column_name
393
382
"this used not to disable the index"
394
383
alter table t1 modify a int;
395
384
show indexes from t1;
396
385
Table Unique Key_name Seq_in_index Column_name
398
387
alter table t1 enable keys;
400
389
Note 1031 Table storage engine for 't1' doesn't have this option
401
390
show indexes from t1;
402
391
Table Unique Key_name Seq_in_index Column_name
404
393
alter table t1 modify a bigint;
405
394
show indexes from t1;
406
395
Table Unique Key_name Seq_in_index Column_name
408
397
alter table t1 enable keys;
410
399
Note 1031 Table storage engine for 't1' doesn't have this option
411
400
show indexes from t1;
412
401
Table Unique Key_name Seq_in_index Column_name
414
403
alter table t1 add b char(10);
415
404
show indexes from t1;
416
405
Table Unique Key_name Seq_in_index Column_name
418
407
alter table t1 add c decimal(10,2);
419
408
show indexes from t1;
420
409
Table Unique Key_name Seq_in_index Column_name
422
411
"this however did"
424
413
show indexes from t1;
425
414
Table Unique Key_name Seq_in_index Column_name
428
417
Field Type Null Default Default_is_NULL On_Update
432
421
alter table t1 add d decimal(15,5);
433
422
"The key should still be disabled"
434
423
show indexes from t1;
435
424
Table Unique Key_name Seq_in_index Column_name
438
427
"Now will test with one unique index"
439
428
create table t1(a int, b char(10), unique(a));
440
429
show indexes from t1;
441
430
Table Unique Key_name Seq_in_index Column_name
444
433
show indexes from t1;
445
434
Table Unique Key_name Seq_in_index Column_name
447
436
alter table t1 enable keys;
449
438
Note 1031 Table storage engine for 't1' doesn't have this option
452
441
alter table t1 modify a int;
453
442
show indexes from t1;
454
443
Table Unique Key_name Seq_in_index Column_name
456
445
"Change the type implying data copy"
457
446
"Unique index, no change"
458
447
alter table t1 modify a bigint;
459
448
show indexes from t1;
460
449
Table Unique Key_name Seq_in_index Column_name
462
451
alter table t1 modify a bigint;
463
452
show indexes from t1;
464
453
Table Unique Key_name Seq_in_index Column_name
466
455
alter table t1 modify a int;
467
456
show indexes from t1;
468
457
Table Unique Key_name Seq_in_index Column_name
471
460
"Now will test with one unique and one non-unique index"
472
461
create table t1(a int, b char(10), unique(a), key(b));
473
462
show indexes from t1;
474
463
Table Unique Key_name Seq_in_index Column_name
478
467
show indexes from t1;
479
468
Table Unique Key_name Seq_in_index Column_name
482
471
alter table t1 enable keys;
484
473
Note 1031 Table storage engine for 't1' doesn't have this option
487
476
alter table t1 modify a int;
488
477
show indexes from t1;
489
478
Table Unique Key_name Seq_in_index Column_name
492
481
alter table t1 enable keys;
494
483
Note 1031 Table storage engine for 't1' doesn't have this option
495
484
show indexes from t1;
496
485
Table Unique Key_name Seq_in_index Column_name
499
488
"Change the type implying data copy"
500
489
"The non-unique index will be disabled"
501
490
alter table t1 modify a bigint;
502
491
show indexes from t1;
503
492
Table Unique Key_name Seq_in_index Column_name
506
495
"Change again the type, but leave the indexes as_is"
507
496
alter table t1 modify a int;
508
497
show indexes from t1;
509
498
Table Unique Key_name Seq_in_index Column_name
512
501
"Try the same. When data is no copied on similar tables, this is noop"
513
502
alter table t1 modify a int;
514
503
show indexes from t1;
515
504
Table Unique Key_name Seq_in_index Column_name
519
508
create database mysqltest;
520
509
create table t1 (c1 int);
536
525
SHOW CREATE TABLE t1;
537
526
Table Create Table
538
527
t1 CREATE TABLE `t1` (
539
`a` INT DEFAULT NULL,
528
`a` int DEFAULT NULL,
541
) ENGINE=DEFAULT ROW_FORMAT='COMPACT' COLLATE = utf8_general_ci
530
) ENGINE=DEFAULT ROW_FORMAT='COMPACT'
542
531
DROP INDEX i1 ON t1;
543
532
SHOW CREATE TABLE t1;
544
533
Table Create Table
545
534
t1 CREATE TABLE `t1` (
547
) ENGINE=DEFAULT ROW_FORMAT='COMPACT' COLLATE = utf8_general_ci
536
) ENGINE=DEFAULT ROW_FORMAT='COMPACT'
549
538
DROP TABLE IF EXISTS bug24219;
550
539
DROP TABLE IF EXISTS bug24219_2;
551
540
CREATE TABLE bug24219 (a INT, INDEX(a));
552
541
SHOW INDEX FROM bug24219;
553
542
Table Unique Key_name Seq_in_index Column_name
555
544
ALTER TABLE bug24219 RENAME TO bug24219_2, DISABLE KEYS;
557
546
Note 1031 Table storage engine for 'bug24219' doesn't have this option
558
547
SHOW INDEX FROM bug24219_2;
559
548
Table Unique Key_name Seq_in_index Column_name
549
bug24219_2 FALSE a 1 a
561
550
DROP TABLE bug24219_2;
562
551
drop table if exists table_24562;
563
552
create table table_24562(
674
663
alter table t1 alter column mycol set default 0;
676
665
Field Type Null Default Default_is_NULL On_Update
677
mycol INTEGER NO 0 NO
666
mycol INTEGER FALSE 0 FALSE
679
668
create TEMPORARY table t1(id int primary key auto_increment) engine=MEMORY;
680
669
insert into t1 values (null);
810
799
SHOW CREATE TABLE `tt+1`;
811
800
Table Create Table
812
801
tt+1 CREATE TEMPORARY TABLE `tt+1` (
813
`c1` INT DEFAULT NULL
814
) ENGINE=DEFAULT COLLATE = utf8_general_ci
802
`c1` int DEFAULT NULL
815
804
SHOW CREATE TABLE `tt+2`;
816
805
Table Create Table
817
806
tt+2 CREATE TEMPORARY TABLE `tt+2` (
818
`c1` INT DEFAULT NULL
819
) ENGINE=DEFAULT COLLATE = utf8_general_ci
807
`c1` int DEFAULT NULL
820
809
DROP TABLE `tt+1`, `tt+2`;
821
810
CREATE TEMPORARY TABLE `#sql1` (c1 INT);
822
811
CREATE TEMPORARY TABLE `@0023sql2` (c1 INT);
835
824
SHOW CREATE TABLE `#sql2`;
836
825
Table Create Table
837
826
#sql2 CREATE TEMPORARY TABLE `#sql2` (
838
`c1` INT DEFAULT NULL
839
) ENGINE=DEFAULT COLLATE = utf8_general_ci
827
`c1` int DEFAULT NULL
840
829
SHOW CREATE TABLE `@0023sql1`;
841
830
Table Create Table
842
831
@0023sql1 CREATE TEMPORARY TABLE `@0023sql1` (
843
`c1` INT DEFAULT NULL
844
) ENGINE=DEFAULT COLLATE = utf8_general_ci
832
`c1` int DEFAULT NULL
845
834
DROP TABLE `#sql2`, `@0023sql1`;
846
835
DROP TABLE IF EXISTS t1;
847
836
DROP TABLE IF EXISTS t2;
854
843
Field Type Null Default Default_is_NULL On_Update
855
int_field INTEGER NO NO
856
char_field VARCHAR YES YES
844
int_field INTEGER FALSE FALSE
845
char_field VARCHAR TRUE TRUE
857
846
SHOW INDEXES FROM t1;
858
847
Table Unique Key_name Seq_in_index Column_name
859
t1 NO int_field 1 int_field
848
t1 FALSE int_field 1 int_field
860
849
INSERT INTO t1 VALUES (1, "edno"), (1, "edno"), (2, "dve"), (3, "tri"), (5, "pet");
861
850
"Non-copy data change - new frm, but old data and index files"
862
851
ALTER TABLE t1 CHANGE int_field unsigned_int_field INTEGER NOT NULL, RENAME t2;
863
852
SELECT * FROM t1 ORDER BY int_field;
864
ERROR 42S02: Unknown table 'test.t1'
853
ERROR 42S02: Table 'test.t1' doesn't exist
865
854
SELECT * FROM t2 ORDER BY unsigned_int_field;
866
855
unsigned_int_field char_field
873
862
Field Type Null Default Default_is_NULL On_Update
874
unsigned_int_field INTEGER NO NO
875
char_field VARCHAR YES YES
863
unsigned_int_field INTEGER FALSE FALSE
864
char_field VARCHAR TRUE TRUE
877
866
Field Type Null Default Default_is_NULL On_Update
878
unsigned_int_field INTEGER NO NO
879
char_field VARCHAR YES YES
867
unsigned_int_field INTEGER FALSE FALSE
868
char_field VARCHAR TRUE TRUE
880
869
ALTER TABLE t2 MODIFY unsigned_int_field BIGINT NOT NULL;
882
871
Field Type Null Default Default_is_NULL On_Update
883
unsigned_int_field BIGINT NO NO
884
char_field VARCHAR YES YES
872
unsigned_int_field BIGINT FALSE FALSE
873
char_field VARCHAR TRUE TRUE
886
875
CREATE TABLE t1 (f1 INT, f2 INT, f3 INT);
887
876
INSERT INTO t1 VALUES (1, 2, NULL);