220
220
CREATE TABLE `job_titles` (
221
`job_title_id` int unsigned NOT NULL default '0',
221
`job_title_id` int(6) 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 unsigned NOT NULL) ENGINE=HEAP;
236
CREATE TABLE t1 (pseudo char(35) PRIMARY KEY, date int(10) 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" (
266
t1 CREATE TABLE `t1` (
267
`v` varchar(10) DEFAULT NULL,
268
`c` char(10) DEFAULT NULL,
269
`t` varchar(50) DEFAULT NULL
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" (
274
t2 CREATE TABLE `t2` (
275
`v` varchar(10) DEFAULT NULL,
276
`c` char(10) DEFAULT NULL,
277
`t` varchar(50) DEFAULT NULL
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" (
282
t3 CREATE TABLE `t3` (
283
`v` varchar(10) DEFAULT NULL,
284
`c` char(10) DEFAULT NULL,
285
`t` varchar(50) DEFAULT NULL
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" (
290
t1 CREATE TABLE `t1` (
291
`v` varchar(10) DEFAULT NULL,
292
`c` varchar(10) DEFAULT NULL,
293
`t` varchar(50) DEFAULT NULL
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" (
298
t1 CREATE TABLE `t1` (
299
`v` char(10) DEFAULT NULL,
300
`c` varchar(10) DEFAULT NULL,
301
`t` varchar(50) DEFAULT NULL
302
302
) ENGINE=MEMORY DEFAULT CHARSET=latin1
303
alter table t1 modify t varchar(50);
303
alter table t1 modify t varchar(10);
305
Warning 1265 Data truncated for column 't' at row 2
304
306
show create table t1;
305
307
Table Create Table
306
t1 CREATE TABLE "t1" (
308
t1 CREATE TABLE `t1` (
309
`v` char(10) DEFAULT NULL,
310
`c` varchar(10) DEFAULT NULL,
311
`t` varchar(10) DEFAULT NULL
310
312
) ENGINE=MEMORY DEFAULT CHARSET=latin1
311
313
select concat('*',v,'*',c,'*',t,'*') from t1;
312
314
concat('*',v,'*',c,'*',t,'*')
315
317
drop table t1,t2,t3;
316
318
create table t1 (v varchar(10), c char(10), t varchar(50), key(v), key(c), key(t(10)));
317
319
show create table t1;
318
320
Table Create Table
319
t1 CREATE TABLE "t1" (
321
t1 CREATE TABLE `t1` (
322
`v` varchar(10) DEFAULT NULL,
323
`c` char(10) DEFAULT NULL,
324
`t` varchar(50) DEFAULT NULL,
326
328
) ENGINE=MEMORY DEFAULT CHARSET=latin1
327
329
select count(*) from t1;
369
371
1 SIMPLE t1 ref v v 13 const 10 Using where
370
372
explain select count(*) from t1 where c='a ';
371
373
id select_type table type possible_keys key key_len ref rows Extra
372
1 SIMPLE t1 ref c c 13 const 10 Using where
374
1 SIMPLE t1 ref c c 11 const 10 Using where
373
375
explain select count(*) from t1 where t='a ';
374
376
id select_type table type possible_keys key key_len ref rows Extra
375
377
1 SIMPLE t1 ref t t 13 const 10 Using where
387
389
select concat('*',v,'*',c,'*',t,'*') as qq from t1 where v='a' order by length(concat('*',v,'*',c,'*',t,'*'));
399
401
explain select * from t1 where v='a';
400
402
id select_type table type possible_keys key key_len ref rows Extra
401
403
1 SIMPLE t1 ref v v 13 const 10 Using where
535
537
create table t1 (a char(10), unique (a));
536
538
insert into t1 values ('a');
537
539
insert into t1 values ('a ');
538
ERROR 23000: Duplicate entry 'a ' for key 'a'
540
ERROR 23000: Duplicate entry 'a' for key 'a'
539
541
alter table t1 modify a varchar(10);
540
542
insert into t1 values ('a '),('a '),('a '),('a ');
541
543
ERROR 23000: Duplicate entry 'a ' for key 'a'
551
553
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)));
552
554
show create table t1;
553
555
Table Create Table
554
t1 CREATE TABLE "t1" (
558
KEY "v" ("v") USING BTREE,
559
KEY "c" ("c") USING BTREE,
560
KEY "t" ("t"(10)) USING BTREE
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
561
563
) ENGINE=MEMORY DEFAULT CHARSET=latin1
562
564
select count(*) from t1;
592
594
1 SIMPLE t1 ref v v 13 const # Using where
593
595
explain select count(*) from t1 where c='a ';
594
596
id select_type table type possible_keys key key_len ref rows Extra
595
1 SIMPLE t1 ref c c 13 const # Using where
597
1 SIMPLE t1 ref c c 11 const # Using where
596
598
explain select count(*) from t1 where t='a ';
597
599
id select_type table type possible_keys key key_len ref rows Extra
598
600
1 SIMPLE t1 ref t t 13 const # Using where
610
612
select concat('*',v,'*',c,'*',t,'*') as qq from t1 where v='a' order by length(concat('*',v,'*',c,'*',t,'*'));
622
624
explain select * from t1 where v='a';
623
625
id select_type table type possible_keys key key_len ref rows Extra
624
626
1 SIMPLE t1 ref v v 13 const # Using where
626
628
create table t1 (a char(10), unique using btree (a)) engine=heap;
627
629
insert into t1 values ('a');
628
630
insert into t1 values ('a ');
629
ERROR 23000: Duplicate entry 'a ' for key 'a'
631
ERROR 23000: Duplicate entry 'a' for key 'a'
630
632
alter table t1 modify a varchar(10);
631
633
insert into t1 values ('a '),('a '),('a '),('a ');
632
634
ERROR 23000: Duplicate entry 'a ' for key 'a'
642
644
create table t1 (v varchar(10), c char(10), t varchar(50), key(v(5)), key(c(5)), key(t(5)));
643
645
show create table t1;
644
646
Table Create Table
645
t1 CREATE TABLE "t1" (
647
t1 CREATE TABLE `t1` (
648
`v` varchar(10) DEFAULT NULL,
649
`c` char(10) DEFAULT NULL,
650
`t` varchar(50) DEFAULT NULL,
652
654
) ENGINE=MEMORY DEFAULT CHARSET=latin1
654
656
create table t1 (v varchar(65530), key(v(10)));
655
657
show create table t1;
656
658
Table Create Table
657
t1 CREATE TABLE "t1" (
659
t1 CREATE TABLE `t1` (
660
`v` varchar(65530) DEFAULT NULL,
660
662
) ENGINE=MEMORY DEFAULT CHARSET=latin1
661
663
insert into t1 values(repeat('a',65530));
662
664
select length(v) from t1 where v=repeat('a',65530);
666
set storage_engine=InnoDB;
668
set storage_engine=MyISAM;
667
669
create table t1 (a bigint unsigned auto_increment primary key, b int,
668
670
key (b, a)) engine=heap;
669
671
insert t1 (b) values (1),(1),(1),(1),(1),(1),(1),(1);
714
716
create table t2 (c varchar(10)) engine=memory;
715
717
show table status like 't_';
716
718
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
717
t1 MEMORY 10 Fixed 0 12 0 # 0 0 NULL NULL NULL NULL latin1_swedish_ci NULL
719
t1 MEMORY 10 Fixed 0 11 0 # 0 0 NULL NULL NULL NULL latin1_swedish_ci NULL
718
720
t2 MEMORY 10 Fixed 0 12 0 # 0 0 NULL NULL NULL NULL latin1_swedish_ci NULL
719
721
drop table t1, t2;
720
722
CREATE TABLE t1(a VARCHAR(1), b VARCHAR(2), c VARCHAR(256),