MySQL-视图
发布日期:2021-08-19 19:59:25 浏览次数:7 分类:技术文章

本文共 808 字,大约阅读时间需要 2 分钟。

视图

1.什么是视图
视图是由查询结果形成的一张虚拟表。
2.什么时候要用视图?
如果某个查询结果出现的非常频繁,要经常拿这个查询结果来做子查询。
3.使用视图的好处?
简化查询语句
可以进行权限控制
大数据表分表
4.视图存放的位置?
information_schema数据库下的views表里。
select * from information_schema.views\G
5.视图管理
查看视图的定义
show table status from sqltest like '%v_test%';
删除视图
drop view if exists v_test restrict| cascade
查看权限
select drop_priv from mysql.user where user='root';
更新视图
update v_test set username='ddd' where id=2;
with check option
更新视图数据,必须满足视图条件
show table
create or replace view v_test
as
select e.id,e.username,d.depName from
employee as e
left join
department as d
on e.depId = d.id
group by
e.id;
create or replace view v_employee1
as
select * from employee where id % 4 = 0;
create or replace view v_employee2
as
select * from employee where id % 4 = 1;

转载于:https://www.cnblogs.com/3ddan/p/10361702.html

转载地址:https://blog.csdn.net/weixin_30951743/article/details/95793936 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:简述web工程师的职责与学习
下一篇:函数-函数进阶-斐波那契

发表评论

最新留言

初次前来,多多关照!
[***.217.46.12]2024年04月08日 07时06分45秒