
1)ALL用在SELECT子句里省略与否,对结果无影响。
例如下列两句是等价的:
select all * from t1
select * from t1
2)ALL用在UNION子句里,则省略与否的输出结果是不一样的。如果使用ALL则保留所有的记录行,反之则剔除有重复的行。
例如:
select col1,col2 from t1 union select col1,col2 from t2
省略了 all 关键字,系统会剔除联合后所有有重复的行,对于有重复的行只保留一行记录。
它相当于select distinct ...
又例如:
select col1,col2 from t1 union all select col1,col2 from t2
此句将保留所有的记录行,不会剔除有重复的行。它相当于 select all ...
select,insert,
update,
delete,
create,
drop,
references,
index,
alter,
create temporary tables,
lock tables,
execute,
create view,
show view,
create routine,
alter routine,
event,
trigger
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)