220
220
CREATE TABLE `job_titles` (
221
`job_title_id` int(6) unsigned NOT NULL default '0',
221
`job_title_id` int unsigned NOT NULL default '0',
222
222
`job_title` char(18) NOT NULL default '',
223
223
PRIMARY KEY (`job_title_id`),
224
224
UNIQUE KEY `job_title_id` (`job_title_id`,`job_title`)
236
CREATE TABLE t1 (pseudo char(35) PRIMARY KEY, date int(10) unsigned NOT NULL) ENGINE=HEAP;
236
CREATE TABLE t1 (pseudo char(35) PRIMARY KEY, date int unsigned NOT NULL) ENGINE=HEAP;
237
237
INSERT INTO t1 VALUES ('massecot',1101106491),('altec',1101106492),('stitch+',1101106304),('Seb Corgan',1101106305),('beerfilou',1101106263),('flaker',1101106529),('joce8',5),('M4vrick',1101106418),('gabay008',1101106525),('Vamp irX',1101106291),('ZoomZip',1101106546),('rip666',1101106502),('CBP ',1101106397),('guezpard',1101106496);
238
238
DELETE FROM t1 WHERE date<1101106546;
239
239
SELECT * FROM t1;
259
259
Note 1265 Data truncated for column 'c' at row 1
260
260
select concat('*',v,'*',c,'*',t,'*') from t1;
261
261
concat('*',v,'*',c,'*',t,'*')
264
264
show create table t1;
265
265
Table Create Table
266
t1 CREATE TABLE `t1` (
267
`v` varchar(10) DEFAULT NULL,
268
`c` char(10) DEFAULT NULL,
269
`t` varchar(50) DEFAULT NULL
266
t1 CREATE TABLE "t1" (
270
270
) ENGINE=MEMORY DEFAULT CHARSET=latin1
271
271
create table t2 like t1;
272
272
show create table t2;
273
273
Table Create Table
274
t2 CREATE TABLE `t2` (
275
`v` varchar(10) DEFAULT NULL,
276
`c` char(10) DEFAULT NULL,
277
`t` varchar(50) DEFAULT NULL
274
t2 CREATE TABLE "t2" (
278
278
) ENGINE=MEMORY DEFAULT CHARSET=latin1
279
279
create table t3 select * from t1;
280
280
show create table t3;
281
281
Table Create Table
282
t3 CREATE TABLE `t3` (
283
`v` varchar(10) DEFAULT NULL,
284
`c` char(10) DEFAULT NULL,
285
`t` varchar(50) DEFAULT NULL
282
t3 CREATE TABLE "t3" (
286
286
) ENGINE=MEMORY DEFAULT CHARSET=latin1
287
287
alter table t1 modify c varchar(10);
288
288
show create table t1;
289
289
Table Create Table
290
t1 CREATE TABLE `t1` (
291
`v` varchar(10) DEFAULT NULL,
292
`c` varchar(10) DEFAULT NULL,
293
`t` varchar(50) DEFAULT NULL
290
t1 CREATE TABLE "t1" (
294
294
) ENGINE=MEMORY DEFAULT CHARSET=latin1
295
295
alter table t1 modify v char(10);
296
296
show create table t1;
297
297
Table Create Table
298
t1 CREATE TABLE `t1` (
299
`v` char(10) DEFAULT NULL,
300
`c` varchar(10) DEFAULT NULL,
301
`t` varchar(50) DEFAULT NULL
298
t1 CREATE TABLE "t1" (
302
302
) ENGINE=MEMORY DEFAULT CHARSET=latin1
303
alter table t1 modify t varchar(10);
305
Warning 1265 Data truncated for column 't' at row 2
303
alter table t1 modify t varchar(50);
306
304
show create table t1;
307
305
Table Create Table
308
t1 CREATE TABLE `t1` (
309
`v` char(10) DEFAULT NULL,
310
`c` varchar(10) DEFAULT NULL,
311
`t` varchar(10) DEFAULT NULL
306
t1 CREATE TABLE "t1" (
312
310
) ENGINE=MEMORY DEFAULT CHARSET=latin1
313
311
select concat('*',v,'*',c,'*',t,'*') from t1;
314
312
concat('*',v,'*',c,'*',t,'*')
317
315
drop table t1,t2,t3;
318
316
create table t1 (v varchar(10), c char(10), t varchar(50), key(v), key(c), key(t(10)));
319
317
show create table t1;
320
318
Table Create Table
321
t1 CREATE TABLE `t1` (
322
`v` varchar(10) DEFAULT NULL,
323
`c` char(10) DEFAULT NULL,
324
`t` varchar(50) DEFAULT NULL,
319
t1 CREATE TABLE "t1" (
328
326
) ENGINE=MEMORY DEFAULT CHARSET=latin1
329
327
select count(*) from t1;
371
369
1 SIMPLE t1 ref v v 13 const 10 Using where
372
370
explain select count(*) from t1 where c='a ';
373
371
id select_type table type possible_keys key key_len ref rows Extra
374
1 SIMPLE t1 ref c c 11 const 10 Using where
372
1 SIMPLE t1 ref c c 13 const 10 Using where
375
373
explain select count(*) from t1 where t='a ';
376
374
id select_type table type possible_keys key key_len ref rows Extra
377
375
1 SIMPLE t1 ref t t 13 const 10 Using where
389
387
select concat('*',v,'*',c,'*',t,'*') as qq from t1 where v='a' order by length(concat('*',v,'*',c,'*',t,'*'));
401
399
explain select * from t1 where v='a';
402
400
id select_type table type possible_keys key key_len ref rows Extra
403
401
1 SIMPLE t1 ref v v 13 const 10 Using where
537
535
create table t1 (a char(10), unique (a));
538
536
insert into t1 values ('a');
539
537
insert into t1 values ('a ');
540
ERROR 23000: Duplicate entry 'a' for key 'a'
538
ERROR 23000: Duplicate entry 'a ' for key 'a'
541
539
alter table t1 modify a varchar(10);
542
540
insert into t1 values ('a '),('a '),('a '),('a ');
543
541
ERROR 23000: Duplicate entry 'a ' for key 'a'
553
551
create table t1 (v varchar(10), c char(10), t varchar(50), key using btree (v), key using btree (c), key using btree (t(10)));
554
552
show create table t1;
555
553
Table Create Table
556
t1 CREATE TABLE `t1` (
557
`v` varchar(10) DEFAULT NULL,
558
`c` char(10) DEFAULT NULL,
559
`t` varchar(50) DEFAULT NULL,
560
KEY `v` (`v`) USING BTREE,
561
KEY `c` (`c`) USING BTREE,
562
KEY `t` (`t`(10)) USING BTREE
554
t1 CREATE TABLE "t1" (
558
KEY "v" ("v") USING BTREE,
559
KEY "c" ("c") USING BTREE,
560
KEY "t" ("t"(10)) USING BTREE
563
561
) ENGINE=MEMORY DEFAULT CHARSET=latin1
564
562
select count(*) from t1;
594
592
1 SIMPLE t1 ref v v 13 const # Using where
595
593
explain select count(*) from t1 where c='a ';
596
594
id select_type table type possible_keys key key_len ref rows Extra
597
1 SIMPLE t1 ref c c 11 const # Using where
595
1 SIMPLE t1 ref c c 13 const # Using where
598
596
explain select count(*) from t1 where t='a ';
599
597
id select_type table type possible_keys key key_len ref rows Extra
600
598
1 SIMPLE t1 ref t t 13 const # Using where
612
610
select concat('*',v,'*',c,'*',t,'*') as qq from t1 where v='a' order by length(concat('*',v,'*',c,'*',t,'*'));
624
622
explain select * from t1 where v='a';
625
623
id select_type table type possible_keys key key_len ref rows Extra
626
624
1 SIMPLE t1 ref v v 13 const # Using where
628
626
create table t1 (a char(10), unique using btree (a)) engine=heap;
629
627
insert into t1 values ('a');
630
628
insert into t1 values ('a ');
631
ERROR 23000: Duplicate entry 'a' for key 'a'
629
ERROR 23000: Duplicate entry 'a ' for key 'a'
632
630
alter table t1 modify a varchar(10);
633
631
insert into t1 values ('a '),('a '),('a '),('a ');
634
632
ERROR 23000: Duplicate entry 'a ' for key 'a'
644
642
create table t1 (v varchar(10), c char(10), t varchar(50), key(v(5)), key(c(5)), key(t(5)));
645
643
show create table t1;
646
644
Table Create Table
647
t1 CREATE TABLE `t1` (
648
`v` varchar(10) DEFAULT NULL,
649
`c` char(10) DEFAULT NULL,
650
`t` varchar(50) DEFAULT NULL,
645
t1 CREATE TABLE "t1" (
654
652
) ENGINE=MEMORY DEFAULT CHARSET=latin1
656
654
create table t1 (v varchar(65530), key(v(10)));
657
655
show create table t1;
658
656
Table Create Table
659
t1 CREATE TABLE `t1` (
660
`v` varchar(65530) DEFAULT NULL,
657
t1 CREATE TABLE "t1" (
662
660
) ENGINE=MEMORY DEFAULT CHARSET=latin1
663
661
insert into t1 values(repeat('a',65530));
664
662
select length(v) from t1 where v=repeat('a',65530);
668
set storage_engine=MyISAM;
666
set storage_engine=InnoDB;
669
667
create table t1 (a bigint unsigned auto_increment primary key, b int,
670
668
key (b, a)) engine=heap;
671
669
insert t1 (b) values (1),(1),(1),(1),(1),(1),(1),(1);
716
714
create table t2 (c varchar(10)) engine=memory;
717
715
show table status like 't_';
718
716
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
719
t1 MEMORY 10 Fixed 0 11 0 # 0 0 NULL NULL NULL NULL latin1_swedish_ci NULL
717
t1 MEMORY 10 Fixed 0 12 0 # 0 0 NULL NULL NULL NULL latin1_swedish_ci NULL
720
718
t2 MEMORY 10 Fixed 0 12 0 # 0 0 NULL NULL NULL NULL latin1_swedish_ci NULL
721
719
drop table t1, t2;
722
720
CREATE TABLE t1(a VARCHAR(1), b VARCHAR(2), c VARCHAR(256),