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?
,使用视图有什么意义?
8 个解决方案
#1
As Quassnoi said, it's useful for granting permission to certain rows in a table.
正如Quassnoi所说,它对于授予表中某些行的权限很有用。
For example, let's say a lecturer at a university needs access to information on students in her classes. She shouldn't have access to the "students" table because she 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 her own students' data, but not the whole "students" table.
例如,假设一所大学的讲师需要访问她班级中学生的信息。她不应该访问“学生”表,因为她可以查找或修改整个大学中任何学生的信息。数据库管理员创建的视图仅显示讲师课程中的学生,并为讲师提供适当的视图权限。现在,讲师可以访问自己学生的数据,但不能访问整个“学生”表。
#2
- Using a view saves you copying and pasting your queries and adds code reusability, so you can change a single view instead of
10
queries in the different places of your code. - Different permissions can be granted on views and tables, so that you can show only a portion of data to a user
- A view can be materialized, which means caching the results of the underlying query
使用视图可以节省您复制和粘贴查询的过程,并增加代码的可重用性,因此您可以在代码的不同位置更改单个视图而不是10个查询。
可以对视图和表授予不同的权限,以便您只能向用户显示一部分数据
视图可以实现,这意味着缓存基础查询的结果
#3
A view can be described as a virtual table, created from a SQL query stored in the database.
视图可以描述为从存储在数据库中的SQL查询创建的虚拟表。
Therefore, the following are aspects to consider in using VIEWS
因此,以下是使用VIEWS时要考虑的方面
-
Performance: it can improve data access performance as queries involving several tables generate transactions already exchanged to generate the view.
性能:它可以提高数据访问性能,因为涉及多个表的查询生成已交换的事务以生成视图。
-
Simplicity: most of the views I work with are data arrangements of columns from 4+ tables, a bunch of inner joins. Once the view is created, your application developers will have to deal with the SELECT statements using column in the same view, hence the term virtual table.
简单性:我使用的大多数视图都是来自4个以上表格的列的数据排列,一组内部联接。创建视图后,应用程序开发人员必须使用同一视图中的列处理SELECT语句,因此称为虚拟表。
-
Security: or just called it access control. Most relational database management system allow properties in the view object that control the type of access. For instance, one can allow users to update a view but only the DBA can make modifications to the tables that compose the view.
安全性:或者只是将其称为访问控制。大多数关系数据库管理系统允许视图对象中的属性控制访问类型。例如,可以允许用户更新视图,但只有DBA可以对组成视图的表进行修改。
#4
Views make SQL easier to write (and read).
视图使SQL更容易编写(和读取)。
You can also use views to control access permissions.
您还可以使用视图来控制访问权限。
#5
A view can be more complicated than just showing certain columns. It is a stored query. Wikipedia has much more detail.
视图可能比仅显示某些列更复杂。这是一个存储的查询。*有更多细节。
#6
refer to this link and u know more about views http://www.sql-server-performance.com/articles/dev/views_in_sql_server_p1.aspx
请参阅此链接,您了解有关视图的更多信息http://www.sql-server-performance.com/articles/dev/views_in_sql_server_p1.aspx
#7
Views are very useful for access permissions. There are multiple other advantages (as stated in those links provided above), but for me the main advantage is the reusability. as Quassnoi writes, you can have a single point where you can edit your query, instead of editing a list of methods.
视图对于访问权限非常有用。还有其他许多优点(如上面提供的那些链接所述),但对我来说,主要优点是可重用性。正如Quassnoi所写,您可以在一个点上编辑查询,而不是编辑方法列表。
Perfect!
#8
Views: 1. View will not store any data 2. Used for Security purpose 3. When the base table is dropped, then the view is no longer accessible 4. One can perform DML operations directly on the view
视图:1。视图不会存储任何数据2.用于安全目的3.删除基表后,视图不再可访问4.可以直接在视图上执行DML操作
Materialized view: 1. Materialized view does not store data 2. It is used for better performance 3. When the base table is dropped, a materialized view is still accessible 4. One cannot perform DML operations on materialized view.
物化视图:1。物化视图不存储数据2.它用于提高性能3.删除基表时,仍可访问物化视图4.无法对物化视图执行DML操作。
Reference: https://www.youtube.com/watch?v=8ySsyZlixuE
#1
As Quassnoi said, it's useful for granting permission to certain rows in a table.
正如Quassnoi所说,它对于授予表中某些行的权限很有用。
For example, let's say a lecturer at a university needs access to information on students in her classes. She shouldn't have access to the "students" table because she 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 her own students' data, but not the whole "students" table.
例如,假设一所大学的讲师需要访问她班级中学生的信息。她不应该访问“学生”表,因为她可以查找或修改整个大学中任何学生的信息。数据库管理员创建的视图仅显示讲师课程中的学生,并为讲师提供适当的视图权限。现在,讲师可以访问自己学生的数据,但不能访问整个“学生”表。
#2
- Using a view saves you copying and pasting your queries and adds code reusability, so you can change a single view instead of
10
queries in the different places of your code. - Different permissions can be granted on views and tables, so that you can show only a portion of data to a user
- A view can be materialized, which means caching the results of the underlying query
使用视图可以节省您复制和粘贴查询的过程,并增加代码的可重用性,因此您可以在代码的不同位置更改单个视图而不是10个查询。
可以对视图和表授予不同的权限,以便您只能向用户显示一部分数据
视图可以实现,这意味着缓存基础查询的结果
#3
A view can be described as a virtual table, created from a SQL query stored in the database.
视图可以描述为从存储在数据库中的SQL查询创建的虚拟表。
Therefore, the following are aspects to consider in using VIEWS
因此,以下是使用VIEWS时要考虑的方面
-
Performance: it can improve data access performance as queries involving several tables generate transactions already exchanged to generate the view.
性能:它可以提高数据访问性能,因为涉及多个表的查询生成已交换的事务以生成视图。
-
Simplicity: most of the views I work with are data arrangements of columns from 4+ tables, a bunch of inner joins. Once the view is created, your application developers will have to deal with the SELECT statements using column in the same view, hence the term virtual table.
简单性:我使用的大多数视图都是来自4个以上表格的列的数据排列,一组内部联接。创建视图后,应用程序开发人员必须使用同一视图中的列处理SELECT语句,因此称为虚拟表。
-
Security: or just called it access control. Most relational database management system allow properties in the view object that control the type of access. For instance, one can allow users to update a view but only the DBA can make modifications to the tables that compose the view.
安全性:或者只是将其称为访问控制。大多数关系数据库管理系统允许视图对象中的属性控制访问类型。例如,可以允许用户更新视图,但只有DBA可以对组成视图的表进行修改。
#4
Views make SQL easier to write (and read).
视图使SQL更容易编写(和读取)。
You can also use views to control access permissions.
您还可以使用视图来控制访问权限。
#5
A view can be more complicated than just showing certain columns. It is a stored query. Wikipedia has much more detail.
视图可能比仅显示某些列更复杂。这是一个存储的查询。*有更多细节。
#6
refer to this link and u know more about views http://www.sql-server-performance.com/articles/dev/views_in_sql_server_p1.aspx
请参阅此链接,您了解有关视图的更多信息http://www.sql-server-performance.com/articles/dev/views_in_sql_server_p1.aspx
#7
Views are very useful for access permissions. There are multiple other advantages (as stated in those links provided above), but for me the main advantage is the reusability. as Quassnoi writes, you can have a single point where you can edit your query, instead of editing a list of methods.
视图对于访问权限非常有用。还有其他许多优点(如上面提供的那些链接所述),但对我来说,主要优点是可重用性。正如Quassnoi所写,您可以在一个点上编辑查询,而不是编辑方法列表。
Perfect!
#8
Views: 1. View will not store any data 2. Used for Security purpose 3. When the base table is dropped, then the view is no longer accessible 4. One can perform DML operations directly on the view
视图:1。视图不会存储任何数据2.用于安全目的3.删除基表后,视图不再可访问4.可以直接在视图上执行DML操作
Materialized view: 1. Materialized view does not store data 2. It is used for better performance 3. When the base table is dropped, a materialized view is still accessible 4. One cannot perform DML operations on materialized view.
物化视图:1。物化视图不存储数据2.它用于提高性能3.删除基表时,仍可访问物化视图4.无法对物化视图执行DML操作。
Reference: https://www.youtube.com/watch?v=8ySsyZlixuE