~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/r/key.result

  • Committer: Monty Taylor
  • Date: 2009-04-14 19:16:51 UTC
  • mto: (997.2.5 mordred)
  • mto: This revision was merged to the branch mainline in revision 994.
  • Revision ID: mordred@inaugust.com-20090414191651-ltbww6hpqks8k7qk
Clarified instructions in README.

Show diffs side-by-side

added added

removed removed

Lines of Context:
95
95
create table t2
96
96
(
97
97
name_id int not null auto_increment,
98
 
name char(255),
 
98
name char(255) binary,
99
99
INDEX name_idx (name(5)),
100
100
primary key (name_id)
101
101
);
124
124
INSERT INTO t1 VALUES (1, 1, 1, 1, 'a');
125
125
ERROR 23000: Duplicate entry '1-1-1-1-a' for key 'PRIMARY'
126
126
drop table t1;
127
 
CREATE TEMPORARY TABLE t1 (
 
127
CREATE TABLE t1 (
128
128
a tinytext NOT NULL,
129
129
b int NOT NULL default '0',
130
130
PRIMARY KEY (a(32),b)
143
143
drop table t1;
144
144
create table t1 (a int not null unique, b int unique, c int, d int not null primary key, key(c), e int not null unique);
145
145
show keys from t1;
146
 
Table   Unique  Key_name        Seq_in_index    Column_name
147
 
t1      TRUE    PRIMARY 1       d
148
 
t1      TRUE    a       1       a
149
 
t1      TRUE    e       1       e
150
 
t1      TRUE    b       1       b
151
 
t1      FALSE   c       1       c
 
146
Table   Non_unique      Key_name        Seq_in_index    Column_name     Collation       Cardinality     Sub_part        Packed  Null    Index_type      Comment Index_Comment
 
147
t1      0       PRIMARY 1       d       A       0       NULL    NULL            BTREE           
 
148
t1      0       a       1       a       A       0       NULL    NULL            BTREE           
 
149
t1      0       e       1       e       A       0       NULL    NULL            BTREE           
 
150
t1      0       b       1       b       A       0       NULL    NULL    YES     BTREE           
 
151
t1      1       c       1       c       A       0       NULL    NULL    YES     BTREE           
152
152
drop table t1;
153
153
CREATE TABLE t1 (c VARCHAR(10) NOT NULL,i INT PRIMARY KEY NOT NULL AUTO_INCREMENT, UNIQUE (c,i));
154
154
INSERT INTO t1 (c) VALUES (NULL),(NULL);
175
175
a       3
176
176
a       4
177
177
drop table t1;
178
 
CREATE TEMPORARY TABLE t1 (id int auto_increment, name char(50), primary key (id)) engine=myisam;
 
178
CREATE TABLE t1 (id int auto_increment, name char(50), primary key (id)) engine=myisam;
179
179
insert into t1 (name) values ('a'), ('b'),('c'),('d'),('e'),('f'),('g');
180
180
explain select 1 from t1 where id =2;
181
181
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
204
204
numeropost
205
205
1
206
206
drop table t1;
207
 
create temporary table t1 (c varchar(30), t text, unique (c(2)), unique (t(3))) engine=myisam;
 
207
create table t1 (c varchar(30), t text, unique (c(2)), unique (t(3))) engine=myisam;
208
208
show create table t1;
209
209
Table   Create Table
210
 
t1      CREATE TEMPORARY TABLE `t1` (
 
210
t1      CREATE TABLE `t1` (
211
211
  `c` varchar(30) DEFAULT NULL,
212
212
  `t` text,
213
 
  UNIQUE KEY `c` (`c`(2)),
214
 
  UNIQUE KEY `t` (`t`(3))
 
213
  UNIQUE KEY `c` (`c`()),
 
214
  UNIQUE KEY `t` (`t`())
215
215
) ENGINE=MyISAM
216
216
insert t1 values ('cccc', 'tttt'),
217
217
(0xD0B1212223D0B1D0B1D0B1D0B1D0B1, 0xD0B1D0B1212223D0B1D0B1D0B1D0B1),
240
240
DROP TABLE IF EXISTS t1;
241
241
Warnings:
242
242
Note    1051    Unknown table 't1'
243
 
CREATE TEMPORARY TABLE t1 (
 
243
CREATE TABLE t1 (
244
244
c1 int,
245
245
c2 varbinary(240),
246
246
UNIQUE KEY (c1),
301
301
UNIQUE i1idx (i1),
302
302
UNIQUE i2idx (i2));
303
303
desc t1;
304
 
Field   Type    Null    Default Default_is_NULL On_Update
305
 
i1      INTEGER FALSE           FALSE   
306
 
i2      INTEGER FALSE           FALSE   
 
304
Field   Type    Null    Key     Default Extra
 
305
i1      int     NO      PRI     NULL    
 
306
i2      int     NO      UNI     NULL    
307
307
show create table t1;
308
308
Table   Create Table
309
309
t1      CREATE TABLE `t1` (
313
313
  UNIQUE KEY `i2idx` (`i2`)
314
314
) ENGINE=InnoDB
315
315
drop table t1;
316
 
create temporary table t1 (
 
316
create table t1 (
317
317
c1 int,
318
318
c2 varchar(20) not null,
319
319
primary key (c1),
357
357
drop table t1;
358
358
create table t1 (a int not null primary key, b varchar(20) not null unique);
359
359
desc t1;
360
 
Field   Type    Null    Default Default_is_NULL On_Update
361
 
a       INTEGER FALSE           FALSE   
362
 
b       VARCHAR FALSE           FALSE   
 
360
Field   Type    Null    Key     Default Extra
 
361
a       int     NO      PRI     NULL    
 
362
b       varchar(20)     NO      UNI     NULL    
363
363
drop table t1;
364
364
create table t1 (a int not null primary key, b int not null unique);
365
365
desc t1;
366
 
Field   Type    Null    Default Default_is_NULL On_Update
367
 
a       INTEGER FALSE           FALSE   
368
 
b       INTEGER FALSE           FALSE   
 
366
Field   Type    Null    Key     Default Extra
 
367
a       int     NO      PRI     NULL    
 
368
b       int     NO      UNI     NULL    
369
369
drop table t1;
370
370
create table t1 (a int not null primary key, b varchar(20) not null, unique (b(10)));
371
371
desc t1;
372
 
Field   Type    Null    Default Default_is_NULL On_Update
373
 
a       INTEGER FALSE           FALSE   
374
 
b       VARCHAR FALSE           FALSE   
 
372
Field   Type    Null    Key     Default Extra
 
373
a       int     NO      PRI     NULL    
 
374
b       varchar(20)     NO      UNI     NULL    
375
375
drop table t1;
376
376
create table t1 (a int not null primary key, b varchar(20) not null, c varchar(20) not null, unique(b(10),c(10)));
377
377
desc t1;
378
 
Field   Type    Null    Default Default_is_NULL On_Update
379
 
a       INTEGER FALSE           FALSE   
380
 
b       VARCHAR FALSE           FALSE   
381
 
c       VARCHAR FALSE           FALSE   
 
378
Field   Type    Null    Key     Default Extra
 
379
a       int     NO      PRI     NULL    
 
380
b       varchar(20)     NO      MUL     NULL    
 
381
c       varchar(20)     NO              NULL    
382
382
drop table t1;
383
383
create table t1 (
384
384
c1 int,
440
440
  KEY `i3` (`c3`),
441
441
  KEY `i2` (`c2`),
442
442
  KEY `i4` (`c4`),
443
 
  KEY `c2` (`c2`(4),`c3`(7))
 
443
  KEY `c2` (`c2`(),`c3`())
444
444
) ENGINE=InnoDB
445
445
insert into t1 values(1, 'a', 'a', NULL);
446
446
insert into t1 values(1, 'b', 'b', NULL);
448
448
alter table t1 add index i3 (c3), add index i2 (c2), add unique index i1 (c1);
449
449
ERROR 23000: Duplicate entry '1' for key 'i1'
450
450
drop table t1;
451
 
CREATE TEMPORARY TABLE t1( a int, KEY(a) ) ENGINE=MyISAM;
 
451
CREATE TABLE t1( a int, KEY(a) ) ENGINE=MyISAM;
452
452
INSERT INTO t1 VALUES( 1 );
453
453
ALTER TABLE t1 DISABLE KEYS;
454
454
EXPLAIN SELECT MAX(a) FROM t1 FORCE INDEX(a);
493
493
b char(10) not null, unique key bb(b(1)), 
494
494
c char(4) not null, unique key cc(c));
495
495
desc t1;
496
 
Field   Type    Null    Default Default_is_NULL On_Update
497
 
a       INTEGER FALSE           FALSE   
498
 
b       VARCHAR FALSE           FALSE   
499
 
c       VARCHAR FALSE           FALSE   
 
496
Field   Type    Null    Key     Default Extra
 
497
a       int     NO      MUL     NULL    
 
498
b       varchar(10)     NO      UNI     NULL    
 
499
c       varchar(4)      NO      PRI     NULL    
500
500
show create table t1;
501
501
Table   Create Table
502
502
t1      CREATE TABLE `t1` (
504
504
  `b` varchar(10) NOT NULL,
505
505
  `c` varchar(4) NOT NULL,
506
506
  UNIQUE KEY `cc` (`c`),
507
 
  UNIQUE KEY `bb` (`b`(1)),
 
507
  UNIQUE KEY `bb` (`b`()),
508
508
  KEY `aa` (`a`)
509
509
) ENGINE=InnoDB
510
510
drop table t1;
512
512
b char(10) not null, unique key bb(b(1)),
513
513
c char(4) not null);
514
514
desc t1;
515
 
Field   Type    Null    Default Default_is_NULL On_Update
516
 
a       INTEGER FALSE           FALSE   
517
 
b       VARCHAR FALSE           FALSE   
518
 
c       VARCHAR FALSE           FALSE   
 
515
Field   Type    Null    Key     Default Extra
 
516
a       int     NO      MUL     NULL    
 
517
b       varchar(10)     NO      UNI     NULL    
 
518
c       varchar(4)      NO              NULL    
519
519
alter table t1 add unique key cc(c);
520
520
desc t1;
521
 
Field   Type    Null    Default Default_is_NULL On_Update
522
 
a       INTEGER FALSE           FALSE   
523
 
b       VARCHAR FALSE           FALSE   
524
 
c       VARCHAR FALSE           FALSE   
 
521
Field   Type    Null    Key     Default Extra
 
522
a       int     NO      MUL     NULL    
 
523
b       varchar(10)     NO      UNI     NULL    
 
524
c       varchar(4)      NO      PRI     NULL    
525
525
show create table t1;
526
526
Table   Create Table
527
527
t1      CREATE TABLE `t1` (
529
529
  `b` varchar(10) NOT NULL,
530
530
  `c` varchar(4) NOT NULL,
531
531
  UNIQUE KEY `cc` (`c`),
532
 
  UNIQUE KEY `bb` (`b`(1)),
 
532
  UNIQUE KEY `bb` (`b`()),
533
533
  KEY `aa` (`a`)
534
534
) ENGINE=InnoDB
535
535
drop table t1;