mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Merge with 4.0.13
This commit is contained in:
@ -138,15 +138,6 @@ id parent_id level
|
||||
1008 102 2
|
||||
1010 102 2
|
||||
1015 102 2
|
||||
explain select level from t1 where level=1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref level level 1 const # Using where; Using index
|
||||
explain select level,id from t1 where level=1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref level level 1 const # Using where; Using index
|
||||
explain select level,id,parent_id from t1 where level=1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref level level 1 const # Using where
|
||||
select level,id from t1 where level=1;
|
||||
level id
|
||||
1 1002
|
||||
@ -208,7 +199,7 @@ create index skr on t1 (a);
|
||||
insert into t1 values (3,""), (4,"testing");
|
||||
analyze table t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze error The storage enginge for the table doesn't support analyze
|
||||
test.t1 analyze status OK
|
||||
show keys from t1;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
|
||||
t1 1 skr 1 a A 3 NULL NULL YES BTREE
|
||||
@ -595,9 +586,6 @@ id parent_id level
|
||||
1009 102 2
|
||||
1025 102 2
|
||||
1016 102 2
|
||||
explain select level from t1 where level=1;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ref level level 1 const 6 Using where; Using index
|
||||
select level,id from t1 where level=1;
|
||||
level id
|
||||
1 1004
|
||||
@ -1141,7 +1129,7 @@ a b
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (a int not null primary key, b int not null, key (b)) type=innodb;
|
||||
CREATE TABLE t2 (a int not null primary key, b int not null, key (b)) type=innodb;
|
||||
INSERT INTO t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9);
|
||||
INSERT INTO t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9),(10,10),(11,11),(12,12);
|
||||
INSERT INTO t2 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9);
|
||||
update t1,t2 set t1.a=t1.a+100;
|
||||
select * from t1;
|
||||
@ -1155,6 +1143,9 @@ a b
|
||||
107 7
|
||||
108 8
|
||||
109 9
|
||||
110 10
|
||||
111 11
|
||||
112 12
|
||||
update t1,t2 set t1.a=t1.a+100 where t1.a=101;
|
||||
select * from t1;
|
||||
a b
|
||||
@ -1167,6 +1158,9 @@ a b
|
||||
107 7
|
||||
108 8
|
||||
109 9
|
||||
110 10
|
||||
111 11
|
||||
112 12
|
||||
update t1,t2 set t1.b=t1.b+10 where t1.b=2;
|
||||
select * from t1;
|
||||
a b
|
||||
@ -1178,8 +1172,11 @@ a b
|
||||
107 7
|
||||
108 8
|
||||
109 9
|
||||
110 10
|
||||
111 11
|
||||
102 12
|
||||
update t1,t2 set t1.b=t1.b+2,t2.b=t1.b where t1.b between 3 and 5;
|
||||
112 12
|
||||
update t1,t2 set t1.b=t1.b+2,t2.b=t1.b+10 where t1.b between 3 and 5 and t1.a=t2.a+100;
|
||||
select * from t1;
|
||||
a b
|
||||
201 1
|
||||
@ -1190,19 +1187,105 @@ a b
|
||||
107 7
|
||||
108 8
|
||||
109 9
|
||||
110 10
|
||||
111 11
|
||||
102 12
|
||||
112 12
|
||||
select * from t2;
|
||||
a b
|
||||
1 5
|
||||
2 5
|
||||
3 5
|
||||
4 5
|
||||
5 5
|
||||
6 5
|
||||
7 5
|
||||
8 5
|
||||
9 5
|
||||
1 1
|
||||
2 2
|
||||
6 6
|
||||
7 7
|
||||
8 8
|
||||
9 9
|
||||
3 13
|
||||
4 14
|
||||
5 15
|
||||
drop table t1,t2;
|
||||
CREATE TABLE t2 ( NEXT_T BIGINT NOT NULL PRIMARY KEY) TYPE=MyISAM;
|
||||
CREATE TABLE t1 ( B_ID INTEGER NOT NULL PRIMARY KEY) TYPE=InnoDB;
|
||||
SET AUTOCOMMIT=0;
|
||||
INSERT INTO t1 ( B_ID ) VALUES ( 1 );
|
||||
INSERT INTO t2 ( NEXT_T ) VALUES ( 1 );
|
||||
ROLLBACK;
|
||||
Warning: Some non-transactional changed tables couldn't be rolled back
|
||||
SELECT * FROM t1;
|
||||
B_ID
|
||||
drop table t1,t2;
|
||||
create table t1 ( pk int primary key, parent int not null, child int not null, index (parent) ) type = innodb;
|
||||
insert into t1 values (1,0,4), (2,1,3), (3,2,1), (4,1,2);
|
||||
select distinct parent,child from t1 order by parent;
|
||||
parent child
|
||||
0 4
|
||||
1 2
|
||||
1 3
|
||||
2 1
|
||||
drop table t1;
|
||||
create table t1 (a int not null auto_increment primary key, b int, c int, key(c)) type=innodb;
|
||||
create table t2 (a int not null auto_increment primary key, b int);
|
||||
insert into t1 (b) values (null),(null),(null),(null),(null),(null),(null);
|
||||
insert into t2 (a) select b from t1;
|
||||
insert into t1 (b) select b from t2;
|
||||
insert into t2 (a) select b from t1;
|
||||
insert into t1 (a) select b from t2;
|
||||
insert into t2 (a) select b from t1;
|
||||
insert into t1 (a) select b from t2;
|
||||
insert into t2 (a) select b from t1;
|
||||
insert into t1 (a) select b from t2;
|
||||
insert into t2 (a) select b from t1;
|
||||
insert into t1 (a) select b from t2;
|
||||
insert into t2 (a) select b from t1;
|
||||
insert into t1 (a) select b from t2;
|
||||
insert into t2 (a) select b from t1;
|
||||
insert into t1 (a) select b from t2;
|
||||
insert into t2 (a) select b from t1;
|
||||
insert into t1 (a) select b from t2;
|
||||
insert into t2 (a) select b from t1;
|
||||
insert into t1 (a) select b from t2;
|
||||
select count(*) from t1;
|
||||
count(*)
|
||||
29267
|
||||
explain select * from t1 where c between 1 and 10000;
|
||||
table type possible_keys key key_len ref rows Extra
|
||||
t1 range c c 5 NULL 1 Using where
|
||||
update t1 set c=a;
|
||||
explain select * from t1 where c between 1 and 10000;
|
||||
table type possible_keys key key_len ref rows Extra
|
||||
t1 ALL c NULL NULL NULL 29537 Using where
|
||||
drop table t1,t2;
|
||||
create table t1 (id int primary key auto_increment, fk int, index index_fk (fk)) type=innodb;
|
||||
insert into t1 (id) values (null),(null),(null),(null),(null);
|
||||
update t1 set fk=69 where fk is null order by id limit 1;
|
||||
SELECT * from t1;
|
||||
id fk
|
||||
2 NULL
|
||||
3 NULL
|
||||
4 NULL
|
||||
5 NULL
|
||||
1 69
|
||||
drop table t1;
|
||||
create table t1 (a int not null, b int not null, key (a));
|
||||
insert into t1 values (1,1),(1,2),(1,3),(3,1),(3,2),(3,3),(3,1),(3,2),(3,3),(2,1),(2,2),(2,3);
|
||||
SET @tmp=0;
|
||||
update t1 set b=(@tmp:=@tmp+1) order by a;
|
||||
update t1 set b=99 where a=1 order by b asc limit 1;
|
||||
update t1 set b=100 where a=1 order by b desc limit 2;
|
||||
update t1 set a=a+10+b where a=1 order by b;
|
||||
select * from t1 order by a,b;
|
||||
a b
|
||||
2 4
|
||||
2 5
|
||||
2 6
|
||||
3 7
|
||||
3 8
|
||||
3 9
|
||||
3 10
|
||||
3 11
|
||||
3 12
|
||||
13 2
|
||||
111 100
|
||||
111 100
|
||||
CREATE TABLE t1 (col1 int(1))TYPE=InnoDB;
|
||||
CREATE TABLE t2 (col1 int(1),stamp TIMESTAMP(+0),INDEX stamp_idx
|
||||
(stamp))TYPE=InnoDB;
|
||||
|
Reference in New Issue
Block a user