SET @@session.default_storage_engine = 'MyISAM';
create table t1 (a int not null,
b int as (-a),
c int as (-a) persistent);
insert into t1 (a) values (1), (1), (2), (2), (3);
create view v1 (d,e) as select abs(b), abs(c) from t1;
select d,e from v1;
d e 11 11 22 22 33
select is_updatable from information_schema.views where table_name='v1';
is_updatable
NO
explain extended select d,e from v1;
id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 5100.00
Warnings:
Note 1003 select abs(`test`.`t1`.`b`) AS `d`,abs(`test`.`t1`.`c`) AS `e` from `test`.`t1`
create algorithm=temptable view v2 (d,e) as select abs(b), abs(c) from t1;
show create view v2;
View Create View character_set_client collation_connection
v2 CREATE ALGORITHM=TEMPTABLE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select abs(`t1`.`b`) AS `d`,abs(`t1`.`c`) AS `e` from `t1` latin1 latin1_swedish_ci
select d,e from v2;
d e 11 11 22 22 33
explain extended select d,e from v2;
id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY <derived2> ALL NULL NULL NULL NULL 5100.00 2 DERIVED t1 ALL NULL NULL NULL NULL 5100.00
Warnings:
Note 1003/* select#1 */ select `v2`.`d` AS `d`,`v2`.`e` AS `e` from `test`.`v2`
create view v3 (d,e) as select d*2, e*2 from v1;
select * from v3;
d e 22 22 44 44 66
explain extended select * from v3;
id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 5100.00
Warnings:
Note 1003 select abs(`test`.`t1`.`b`) * 2 AS `d`,abs(`test`.`t1`.`c`) * 2 AS `e` from `test`.`t1`
drop view v1,v2,v3;
drop table t1;
create table t1 (a int not null,
b int as (-a),
c int as (-a) persistent);
insert into t1 (a) values (1), (2), (3), (1), (2), (3);
create view v1 as select distinct b from t1;
select * from v1;
b
-1
-2
-3
explain select * from v1;
id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY <derived2> ALL NULL NULL NULL NULL 6 2 DERIVED t1 ALL NULL NULL NULL NULL 6 Using temporary
select * from t1;
a b c 1 -1 -1 2 -2 -2 3 -3 -3 1 -1 -1 2 -2 -2 3 -3 -3
drop view v1;
create view v1 as select distinct c from t1;
select * from v1;
c
-1
-2
-3
explain select * from v1;
id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY <derived2> ALL NULL NULL NULL NULL 6 2 DERIVED t1 ALL NULL NULL NULL NULL 6 Using temporary
select * from t1;
a b c 1 -1 -1 2 -2 -2 3 -3 -3 1 -1 -1 2 -2 -2 3 -3 -3
drop view v1;
drop table t1;
create table t1 (a int not null,
b int as (-a),
c int as (-a) persistent);
insert into t1 (a) values (1), (2), (3), (4);
create view v1 as select b+1 from t1 order by 1 desc limit 2;
select * from v1;
b+1 0
-1
MariaDB-5.3: the following EXPLAIN produces incorrect #rows for table t1.
MariaDB-5.3: this is expected to go away when FROM subquery optimizations are pushed
explain select * from v1;
id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 2 DERIVED t1 ALL NULL NULL NULL NULL 4 Using filesort
drop view v1;
create view v1 as select c+1 from t1 order by 1 desc limit 2;
select * from v1;
c+1 0
-1
MariaDB-5.3: the following EXPLAIN produces incorrect #rows for table t1.
MariaDB-5.3: this is expected to go away when FROM subquery optimizations are pushed
explain select * from v1;
id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 2 DERIVED t1 ALL NULL NULL NULL NULL 4 Using filesort
drop view v1;
drop table t1;
create table t1 (a int,
b int,
c int as (-a),
d int as (-a) persistent,
primary key(a));
insert into t1 (a,b) values (10,2), (20,3), (30,4), (40,5), (50,10);
create view v1 (a,e,f,g) as select a, b+1,c+1,d+1 from t1;
update v1 set a=a+e;
select * from v1;
a e f g 133 -12 -12 244 -23 -23 355 -34 -34 466 -45 -45 6111 -60 -60
select * from t1;
a b c d 132 -13 -13 243 -24 -24 354 -35 -35 465 -46 -46 6110 -61 -61
delete from v1;
select * from v1;
a e f g
select * from t1;
a b c d
insert into v1 (a,e) values (60,15); ERROR HY000: The target table v1 of the INSERT is not insertable-into
drop table t1;
drop view v1; SET @save_optimizer_switch=@@optimizer_switch; SET optimizer_switch='outer_join_with_cache=off';
create table t1 (a int,
b int as (-a),
c int as (-a) persistent,
primary key(a));
insert into t1 (a) values (1), (2), (3);
create view v1 (x,y,z) as select a,b,c from t1 where b < -1;
select t1.a, v1.x, v1.y, v1.z from t1 left join v1 on (t1.b= v1.y);
a x y z 1 NULL NULL NULL 22 -2 -2 33 -3 -3
drop view v1;
create view v1 (x,y,z) as select a,b,c from t1 where c < -1;
select t1.a, v1.x, v1.y, v1.z from t1 left join v1 on (t1.c= v1.z);
a x y z 1 NULL NULL NULL 22 -2 -2 33 -3 -3
drop view v1;
drop table t1; SET optimizer_switch=@save_optimizer_switch;
create table t1 (a1 int,
b1 int as (-a1),
c1 int as (-a1) persistent);
create table t2 (a2 int,
b2 int as (-a2),
c2 int as (-a2) persistent);
insert into t1 (a1) values (1), (2);
insert into t2 (a2) values (2), (3);
create view v1 as select * from t1,t2 union all select * from t1,t2;
select * from v1;
a1 b1 c1 a2 b2 c2 1 -1 -12 -2 -2 2 -2 -22 -2 -2 1 -1 -13 -3 -3 2 -2 -23 -3 -3 1 -1 -12 -2 -2 2 -2 -22 -2 -2 1 -1 -13 -3 -3 2 -2 -23 -3 -3
drop view v1;
drop table t1, t2;
create table t1 (a int,
b int as (-a),
c int as (-a) persistent);
create table t2 like t1;
create view v1 as select a,b,c from t1;
create view v2 as select a,b,c from t2 where b in (select b from v1);
show create view v2;
View Create View character_set_client collation_connection
v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `t2`.`a` AS `a`,`t2`.`b` AS `b`,`t2`.`c` AS `c` from `t2` where `t2`.`b` in (select `v1`.`b` from `v1`) latin1 latin1_swedish_ci
drop view v2, v1;
drop table t1, t2;
create table t1 (a int,
b int as (-a),
c int as (-a) persistent);
insert into t1 (a) values (1),(1),(2),(2),(3),(3);
create view v1 as select b from t1;
select distinct b from v1;
b
-1
-2
-3
select distinct b from v1 limit 2;
b
-1
-2
select distinct b from t1 limit 2;
b
-1
-2
prepare stmt1 from "select distinct b from v1 limit 2";
execute stmt1;
b
-1
-2
execute stmt1;
b
-1
-2
deallocate prepare stmt1;
drop view v1;
create view v1 as select c from t1;
select distinct c from v1;
c
-1
-2
-3
select distinct c from v1 limit 2;
c
-1
-2
select distinct c from t1 limit 2;
c
-1
-2
prepare stmt1 from "select distinct c from v1 limit 2";
execute stmt1;
c
-1
-2
execute stmt1;
c
-1
-2
deallocate prepare stmt1;
drop view v1;
drop table t1;
create table t1 (a int,
b int as (-a),
c int as (-a) persistent);
create view v1 as select * from t1 where b > -2 && c >-2 with check option;
insert into v1 (a) values (1);
insert into v1 (a) values (3); ERROR44000: CHECK OPTION failed `test`.`v1`
insert ignore into v1 (a) values (2),(3),(0);
Warnings:
Warning 1369 CHECK OPTION failed `test`.`v1`
Warning 1369 CHECK OPTION failed `test`.`v1`
select * from t1;
a b c 1 -1 -1 000
drop view v1;
drop table t1;
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.12 Sekunden
(vorverarbeitet am 2026-10-10)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.