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
create table t1 (bandID INT NOT NULL PRIMARY KEY, payoutID int NOT NULL);
21
create table t1 (bandID INT UNSIGNED NOT NULL PRIMARY KEY, payoutID SMALLINT UNSIGNED 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);
34
23
alter table t1 add column new_col int;
58
GROUP_ID int DEFAULT '0' NOT NULL,
59
LANG_ID int DEFAULT '0' NOT NULL,
47
GROUP_ID int unsigned DEFAULT '0' NOT NULL,
48
LANG_ID smallint unsigned DEFAULT '0' NOT NULL,
60
49
NAME varchar(80) DEFAULT '' NOT NULL,
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 unsigned NULL NO PRI NULL #
56
LANG_ID smallint unsigned NULL NO PRI NULL #
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);
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',
70
id int unsigned NOT NULL default '0',
71
category_id tinyint unsigned NOT NULL default '0',
72
type_id tinyint unsigned NOT NULL default '0',
84
73
body text NOT NULL,
85
user_id int NOT NULL default '0',
74
user_id int unsigned NOT NULL default '0',
86
75
status enum('new','old') NOT NULL default 'new',
89
78
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);
80
CREATE TABLE t1 (AnamneseId int unsigned 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
89
create table t1 (i int unsigned not null auto_increment primary key);
92
90
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);
91
alter table t1 drop i,add i int unsigned 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
create table t1 (i int not null auto_increment primary key);
183
create table t1 (i int unsigned 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 unsigned 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 10 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 10 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 10 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,
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;
535
584
CREATE INDEX i1 ON t1(a);
536
585
SHOW CREATE TABLE t1;
537
586
Table Create Table
538
587
t1 CREATE TABLE `t1` (
539
`a` INT DEFAULT NULL,
541
) ENGINE=DEFAULT ROW_FORMAT='COMPACT' COLLATE = utf8_general_ci
590
) ENGINE=InnoDB ROW_FORMAT=FIXED
542
591
DROP INDEX i1 ON t1;
543
592
SHOW CREATE TABLE t1;
544
593
Table Create Table
545
594
t1 CREATE TABLE `t1` (
547
) ENGINE=DEFAULT ROW_FORMAT='COMPACT' COLLATE = utf8_general_ci
596
) ENGINE=InnoDB ROW_FORMAT=FIXED
549
598
DROP TABLE IF EXISTS bug24219;
550
599
DROP TABLE IF EXISTS bug24219_2;
551
600
CREATE TABLE bug24219 (a INT, INDEX(a));
552
601
SHOW INDEX FROM bug24219;
553
Table Unique Key_name Seq_in_index Column_name
602
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
603
bug24219 1 a 1 a A 0 NULL NULL YES BTREE
555
604
ALTER TABLE bug24219 RENAME TO bug24219_2, DISABLE KEYS;
557
606
Note 1031 Table storage engine for 'bug24219' doesn't have this option
558
607
SHOW INDEX FROM bug24219_2;
559
Table Unique Key_name Seq_in_index Column_name
608
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
609
bug24219_2 1 a 1 a A 0 NULL NULL YES BTREE
561
610
DROP TABLE bug24219_2;
562
611
drop table if exists table_24562;
563
612
create table table_24562(
662
711
3 3 Stored Functions You
664
713
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
714
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '12' at line 1
666
715
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
716
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(section + 12)' at line 1
668
717
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
718
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(title)' at line 1
670
719
alter table table_24562 order by no_such_col;
671
720
ERROR 42S22: Unknown column 'no_such_col' in 'order clause'
672
721
drop table table_24562;
673
722
create table t1 (mycol int not null);
674
723
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
725
Field Type Null Key Default Extra
679
create TEMPORARY table t1(id int primary key auto_increment) engine=MEMORY;
728
create table t1(id int primary key auto_increment) engine=heap;
680
729
insert into t1 values (null);
681
730
insert into t1 values (null);
682
731
select * from t1;
847
drop table if exists t1, t2, t3;
848
create table t1 (i int);
849
create table t3 (j int);
850
insert into t1 values ();
851
insert into t3 values ();
852
lock table t1 write, t3 read;
853
alter table t1 modify i int default 1;
854
insert into t1 values ();
859
alter table t1 change i c char(10) default "Two";
860
insert into t1 values ();
866
alter table t1 modify c char(10) default "Three", rename to t2;
868
ERROR HY000: Table 't1' was not locked with LOCK TABLES
870
ERROR HY000: Table 't2' was not locked with LOCK TABLES
875
insert into t2 values ();
882
lock table t2 write, t3 read;
883
alter table t2 change c vc varchar(100) default "Four", rename to t1;
885
ERROR HY000: Table 't1' was not locked with LOCK TABLES
887
ERROR HY000: Table 't2' was not locked with LOCK TABLES
892
insert into t1 values ();
798
901
DROP TABLE IF EXISTS `t+1`, `t+2`;
799
902
CREATE TABLE `t+1` (c1 INT);
800
903
ALTER TABLE `t+1` RENAME `t+2`;
801
904
CREATE TABLE `t+1` (c1 INT);
802
905
ALTER TABLE `t+1` RENAME `t+2`;
803
ERROR 42S01: Table 'test.t+2' already exists
906
ERROR 42S01: Table 't+2' already exists
804
907
DROP TABLE `t+1`, `t+2`;
805
908
CREATE TEMPORARY TABLE `tt+1` (c1 INT);
806
909
ALTER TABLE `tt+1` RENAME `tt+2`;
807
910
CREATE TEMPORARY TABLE `tt+1` (c1 INT);
808
911
ALTER TABLE `tt+1` RENAME `tt+2`;
809
ERROR 42S01: Table 'test.#tt+2' already exists
912
ERROR 42S01: Table 'tt+2' already exists
810
913
SHOW CREATE TABLE `tt+1`;
811
914
Table Create Table
812
915
tt+1 CREATE TEMPORARY TABLE `tt+1` (
813
`c1` INT DEFAULT NULL
814
) ENGINE=DEFAULT COLLATE = utf8_general_ci
815
918
SHOW CREATE TABLE `tt+2`;
816
919
Table Create Table
817
920
tt+2 CREATE TEMPORARY TABLE `tt+2` (
818
`c1` INT DEFAULT NULL
819
) ENGINE=DEFAULT COLLATE = utf8_general_ci
820
923
DROP TABLE `tt+1`, `tt+2`;
821
924
CREATE TEMPORARY TABLE `#sql1` (c1 INT);
822
925
CREATE TEMPORARY TABLE `@0023sql2` (c1 INT);
827
928
ALTER TABLE `#sql1` RENAME `@0023sql1`;
828
929
ALTER TABLE `@0023sql2` RENAME `#sql2`;
833
932
INSERT INTO `#sql2` VALUES (1);
834
933
INSERT INTO `@0023sql1` VALUES (2);
835
934
SHOW CREATE TABLE `#sql2`;
836
935
Table Create Table
837
936
#sql2 CREATE TEMPORARY TABLE `#sql2` (
838
`c1` INT DEFAULT NULL
839
) ENGINE=DEFAULT COLLATE = utf8_general_ci
840
939
SHOW CREATE TABLE `@0023sql1`;
841
940
Table Create Table
842
941
@0023sql1 CREATE TEMPORARY TABLE `@0023sql1` (
843
`c1` INT DEFAULT NULL
844
) ENGINE=DEFAULT COLLATE = utf8_general_ci
845
944
DROP TABLE `#sql2`, `@0023sql1`;
846
945
DROP TABLE IF EXISTS t1;
847
946
DROP TABLE IF EXISTS t2;
848
947
CREATE TABLE t1 (
849
int_field INTEGER NOT NULL,
948
int_field INTEGER UNSIGNED NOT NULL,
850
949
char_field CHAR(10),
851
950
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
953
Field Type Null Key Default Extra
954
int_field int unsigned NO MUL NULL
955
char_field varchar(10) YES NULL
857
956
SHOW INDEXES FROM t1;
858
Table Unique Key_name Seq_in_index Column_name
859
t1 NO int_field 1 int_field
957
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_Comment
958
t1 1 int_field 1 int_field A 0 NULL NULL BTREE
860
959
INSERT INTO t1 VALUES (1, "edno"), (1, "edno"), (2, "dve"), (3, "tri"), (5, "pet");
861
960
"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;
962
CHANGE int_field unsigned_int_field INTEGER UNSIGNED NOT NULL,
863
964
SELECT * FROM t1 ORDER BY int_field;
864
965
ERROR 42S02: Table 'test.t1' doesn't exist
865
966
SELECT * FROM t2 ORDER BY unsigned_int_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
974
Field Type Null Key Default Extra
975
unsigned_int_field int unsigned NO MUL NULL
976
char_field varchar(10) YES NULL
978
Field Type Null Key Default Extra
979
unsigned_int_field int unsigned NO MUL NULL
980
char_field varchar(10) YES NULL
981
ALTER TABLE t2 MODIFY unsigned_int_field BIGINT UNSIGNED NOT NULL;
983
Field Type Null Key Default Extra
984
unsigned_int_field bigint unsigned 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);