什么是Oracle中的View?

编程入门 行业动态 更新时间:2024-10-26 12:22:50
本文介绍了什么是Oracle中的View?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

什么是Oracle中的视图?

What is a view in Oracle?

推荐答案

A 在Oracle中查看系统只是存储在内存中的SQL语句的表示,以便可以轻松地重新使用。例如,如果我们经常发出以下查询:

A View in Oracle and in other database systems is simply the representation of a SQL statement that is stored in memory so that it can easily be re-used. For example, if we frequently issue the following query

SELECT customerid, customername FROM customers WHERE countryid='US';

要创建视图,请使用 CREATE VIEW命令

CREATE VIEW view_uscustomers AS SELECT customerid, customername FROM customers WHERE countryid='US';

此命令创建一个名为view_uscustomers的新视图。请注意,除了定义此视图的数据字典条目外,此命令不会导致任何实际存储在数据库中。这意味着每次查询此视图时,Oracle都必须出去执行视图并查询数据库数据。我们可以这样查询视图:

This command creates a new view called view_uscustomers. Note that this command does not result in anything being actually stored in the database at all except for a data dictionary entry that defines this view. This means that every time you query this view, Oracle has to go out and execute the view and query the database data. We can query the view like this:

SELECT * FROM view_uscustomers WHERE customerid BETWEEN 100 AND 200;

Oracle会将查询转换为:

And Oracle will transform the query into this:

SELECT * FROM (select customerid, customername from customers WHERE countryid='US') WHERE customerid BETWEEN 100 AND 200

使用视图的好处

  • 正在使用的代码的通用性。因为一个视图是基于一个公共的SQL集合,这意味着当它被调用时,它不太可能需要解析。
  • 安全性。视图长期以来被用于隐藏实际包含您正在查询的数据的表。此外,视图可用于限制给定用户有权访问的列。
  • 推断谓词
  • Commonality of code being used. Since a view is based on one common set of SQL, this means that when it is called it’s less likely to require parsing.
  • Security. Views have long been used to hide the tables that actually contain the data you are querying. Also, views can be used to restrict the columns that a given user has access to.
  • Predicate pushing

您可以在本文中找到有关如何在Oracle中创建和管理视图。

You can find advanced topics in this article about "How to Create and Manage Views in Oracle."

更多推荐

什么是Oracle中的View?

本文发布于:2023-06-05 01:12:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/508802.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Oracle   View

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!