问题描述
如果视图用于向用户显示选定的列,同样可以使用
If views are used to show selected columns to the user, and same can be done by using
SELECT col1, col2
FROM xyz
,使用视图有什么意义?
, what is the point of using views?
推荐答案
正如 Quassnoi 所说,它对于向表中的某些行授予权限很有用.
As Quassnoi said, it's useful for granting permission to certain rows in a table.
例如,假设一所大学的讲师需要访问有关其学生的信息.讲师不应访问学生"表,因为他们可以查找或修改整个大学中任何学生的信息.数据库管理员创建了一个仅显示讲师班级学生的视图,并为讲师授予该视图的适当权限.现在,讲师可以访问自己学生的数据,但不能访问整个学生"表.
For example, let's say a lecturer at a university needs access to information on their students. The lecturer shouldn't have access to the "students" table because they could look up or modify information for any student in the whole university. The database admin makes a view that only shows students from the lecturers classes, and gives the lecturer the appropriate permissions for the view. Now the lecturer has access to their own students' data but not the whole "students" table.
这篇关于视图和 SELECT 查询之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!