新建视图 点击视图 ctrl+s保存
SELECT s_id,s_name,s_class from student
![](https://img.haomeiwen.com/i8484713/9f215a5a12ff2533.png)
![](https://img.haomeiwen.com/i8484713/039436cffac7b663.png)
![](https://img.haomeiwen.com/i8484713/b36c797a103d9b2d.png)
![](https://img.haomeiwen.com/i8484713/01f7cd48e864fc99.png)
视图的查询
image.png
视图的脚本语句的创建
create view newview as select * from student
![](https://img.haomeiwen.com/i8484713/f057ff5b4cef06a7.png)
![](https://img.haomeiwen.com/i8484713/d38c68af3c46c38e.png)
视图与表之间能互相影响,同步数据改变 但很少用视图去修改元数据
存储过程(函数)
选函数
BEGIN
SELECT count(*)into zongshu from student where s_sex = '男';
END
![](https://img.haomeiwen.com/i8484713/747864aae7327d2a.png)
![](https://img.haomeiwen.com/i8484713/5bbe201d2d77cb4c.png)
BEGIN
if sex then
select count(*) into shu from student where s_sex = '女';
else
select count(*) into shu from student where s_sex = '男';
end if;
END
![](https://img.haomeiwen.com/i8484713/a1119cfff46e88ac.png)
网友评论