~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/r/alter_table.result

  • Committer: Brian Aker
  • Date: 2009-10-16 10:27:33 UTC
  • mfrom: (1183.1.4 merge)
  • Revision ID: brian@gaz-20091016102733-b10po5oup0hjlilh
MergeĀ EngineĀ changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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);
11
 
SELECT * FROM t1;
12
 
col1    col2    col3    col4    col5    col6    to_be_deleted
13
 
2       4       3       5       PENDING 1       7
14
11
alter table t1
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
21
 
alter table t1
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;
28
17
select * from t1;
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
31
20
drop table t1;
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),
62
51
KEY NAME (NAME));
63
52
ALTER TABLE t1 CHANGE NAME NAME CHAR(80) not null;
64
 
show COLUMNS FROM t1;
65
 
Field   Type    Null    Default Default_is_NULL On_Update
66
 
GROUP_ID        INTEGER NO      0       NO      
67
 
LANG_ID INTEGER NO      0       NO      
68
 
NAME    VARCHAR NO              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            #       
69
58
DROP TABLE t1;
70
59
create table t1 (n int);
71
60
insert into t1 values(9),(3),(12),(10);
110
99
name
111
100
mysqltest
112
101
alter table t1 rename mysqltest.t1;
113
 
ERROR 42S01: Table 'mysqltest.t1' already exists
 
102
ERROR 42S01: Table 't1' already exists
114
103
select * from t1;
115
104
name
116
105
current
127
116
key (n4, n1, n2, n3) );
128
117
alter table t1;
129
118
show keys from t1;
130
 
Table   Unique  Key_name        Seq_in_index    Column_name
131
 
t1      YES     n1      1       n1
132
 
t1      NO      n1_2    1       n1
133
 
t1      NO      n1_2    2       n2
134
 
t1      NO      n1_2    3       n3
135
 
t1      NO      n1_2    4       n4
136
 
t1      NO      n2      1       n2
137
 
t1      NO      n2      2       n3
138
 
t1      NO      n2      3       n4
139
 
t1      NO      n2      4       n1
140
 
t1      NO      n3      1       n3
141
 
t1      NO      n3      2       n4
142
 
t1      NO      n3      3       n1
143
 
t1      NO      n3      4       n2
144
 
t1      NO      n4      1       n4
145
 
t1      NO      n4      2       n1
146
 
t1      NO      n4      3       n2
147
 
t1      NO      n4      4       n3
 
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;
149
138
begin;
150
139
insert into t1 values(10,RAND()*1000,RAND()*1000,RAND());
163
152
Warnings:
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
167
 
t1      YES     n1      1       n1
168
 
t1      NO      n1_2    1       n1
169
 
t1      NO      n1_2    2       n2
170
 
t1      NO      n1_2    3       n3
171
 
t1      NO      n1_2    4       n4
172
 
t1      NO      n2      1       n2
173
 
t1      NO      n2      2       n3
174
 
t1      NO      n2      3       n4
175
 
t1      NO      n2      4       n1
176
 
t1      NO      n3      1       n3
177
 
t1      NO      n3      2       n4
178
 
t1      NO      n3      3       n1
179
 
t1      NO      n3      4       n2
180
 
t1      NO      n4      1       n4
181
 
t1      NO      n4      2       n1
182
 
t1      NO      n4      3       n2
183
 
t1      NO      n4      4       n3
 
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           
184
173
drop table t1;
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
190
 
i       INTEGER NO              NO      
191
 
c       VARCHAR YES             YES     
 
178
Field   Type    Null    Key     Default Extra
 
179
i       int     NO      PRI     NULL    auto_increment
 
180
c       varchar(10)     YES             NULL    
192
181
drop table t1;
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
301
 
t1      YES     a       1       a
302
 
t1      YES     a       2       b
303
 
t1      NO      b       1       b
 
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
309
 
t1      YES     a       1       a
310
 
t1      YES     a       2       b
311
 
t1      NO      b       1       b
 
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           
312
301
drop table t1;
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),
317
306
KEY  (Host)
318
307
) ENGINE=MyISAM;
319
308
ALTER TABLE t1 DISABLE KEYS;
 
309
SHOW INDEX FROM t1;
 
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','');
 
315
SHOW INDEX FROM t1;
 
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;
 
321
SHOW INDEX FROM t1;
 
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           
322
326
CHECK TABLES t1;
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
355
357
drop table t1;
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
361
362
drop table t1;
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` (
367
 
  `a` INT NOT NULL,
368
 
  `b` INT DEFAULT NULL,
 
368
  `a` int NOT NULL,
 
369
  `b` int DEFAULT NULL,
369
370
  UNIQUE KEY `b` (`b`)
370
 
) ENGINE=DEFAULT COLLATE = utf8_general_ci
 
371
) ENGINE=DEFAULT
371
372
ALTER TABLE t1 DROP PRIMARY KEY;
372
373
ERROR 42000: Can't DROP 'PRIMARY'; check that column/key exists
373
374
DROP TABLE t1;
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
 
t1      NO      a       1       a
 
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
 
t1      NO      a       1       a
 
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;
399
400
Warnings:
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
 
t1      NO      a       1       a
 
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
 
t1      NO      a       1       a
 
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;
409
410
Warnings:
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
 
t1      NO      a       1       a
 
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
 
t1      NO      a       1       a
 
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
 
t1      NO      a       1       a
 
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"
423
424
alter table t1;
424
425
show indexes from t1;
425
 
Table   Unique  Key_name        Seq_in_index    Column_name
426
 
t1      NO      a       1       a
 
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           
427
428
desc t1;
428
 
Field   Type    Null    Default Default_is_NULL On_Update
429
 
a       BIGINT  YES             YES     
430
 
b       VARCHAR YES             YES     
431
 
c       DECIMAL YES             YES     
 
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
 
t1      NO      a       1       a
 
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           
437
438
drop table t1;
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
 
t1      YES     a       1       a
 
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           
443
444
alter table t1;
444
445
show indexes from t1;
445
 
Table   Unique  Key_name        Seq_in_index    Column_name
446
 
t1      YES     a       1       a
 
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;
448
449
Warnings:
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
 
t1      YES     a       1       a
 
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
 
t1      YES     a       1       a
 
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
 
t1      YES     a       1       a
 
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
 
t1      YES     a       1       a
 
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           
470
471
drop table t1;
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
 
t1      YES     a       1       a
476
 
t1      NO      b       1       b
 
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           
477
478
alter table t1;
478
479
show indexes from t1;
479
 
Table   Unique  Key_name        Seq_in_index    Column_name
480
 
t1      YES     a       1       a
481
 
t1      NO      b       1       b
 
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;
483
484
Warnings:
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
 
t1      YES     a       1       a
491
 
t1      NO      b       1       b
 
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;
493
494
Warnings:
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
 
t1      YES     a       1       a
498
 
t1      NO      b       1       b
 
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
 
t1      YES     a       1       a
505
 
t1      NO      b       1       b
 
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
 
t1      YES     a       1       a
511
 
t1      NO      b       1       b
 
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
 
t1      YES     a       1       a
517
 
t1      NO      b       1       b
 
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           
518
519
drop table t1;
519
520
create database mysqltest;
520
521
create table t1 (c1 int);
527
528
use mysqltest;
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;
532
533
use test;
533
534
drop table t1;
534
 
CREATE TABLE t1(a INT) ROW_FORMAT=COMPACT;
 
535
CREATE TABLE t1(a INT) ROW_FORMAT=FIXED;
 
536
Warnings:
 
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,
540
543
  KEY `i1` (`a`)
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` (
546
 
  `a` INT DEFAULT NULL
547
 
) ENGINE=DEFAULT ROW_FORMAT='COMPACT' COLLATE = utf8_general_ci
 
549
  `a` int DEFAULT NULL
 
550
) ENGINE=DEFAULT ROW_FORMAT=FIXED
548
551
DROP TABLE t1;
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
554
 
bug24219        NO      a       1       a
 
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;
556
559
Warnings:
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
560
 
bug24219_2      NO      a       1       a
 
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;
675
678
desc t1;
676
 
Field   Type    Null    Default Default_is_NULL On_Update
677
 
mycol   INTEGER NO      0       NO      
 
679
Field   Type    Null    Key     Default Extra
 
680
mycol   int     NO              0       
678
681
drop table t1;
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;
691
694
1
692
695
2
693
696
50
694
 
alter table t1 engine = MEMORY;
 
697
alter table t1 engine = heap;
695
698
insert into t1 values (null);
696
699
select * from t1;
697
700
id
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;
760
763
drop table t1;
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;
764
767
LENGTH(s)
765
768
4
766
 
ALTER TABLE t1 MODIFY s CHAR(10);
 
769
ALTER TABLE t1 MODIFY s CHAR(10) BINARY;
767
770
SELECT LENGTH(s) FROM t1;
768
771
LENGTH(s)
769
772
4
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
 
817
) ENGINE=DEFAULT
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
 
822
) ENGINE=DEFAULT
820
823
DROP TABLE   `tt+1`, `tt+2`;
821
824
CREATE TEMPORARY TABLE `#sql1` (c1 INT);
822
825
CREATE TEMPORARY TABLE `@0023sql2` (c1 INT);
823
826
SHOW TABLES;
824
827
Tables_in_test
825
 
#sql1
826
 
@0023sql2
827
828
ALTER TABLE `#sql1`      RENAME `@0023sql1`;
828
829
ALTER TABLE `@0023sql2`  RENAME `#sql2`;
829
830
SHOW TABLES;
830
831
Tables_in_test
831
 
#sql2
832
 
@0023sql1
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
 
838
) ENGINE=DEFAULT
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
 
843
) ENGINE=DEFAULT
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`)
852
851
);
853
852
DESCRIBE t1;
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
867
866
1       edno
870
869
3       tri
871
870
5       pet
872
871
DESCRIBE t2;
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    
876
875
DESCRIBE t2;
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;
881
880
DESCRIBE t2;
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    
885
884
DROP TABLE t2;
886
885
CREATE TABLE t1 (f1 INT, f2 INT, f3 INT);
887
886
INSERT INTO t1 VALUES (1, 2, NULL);