In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly shows you "what is the use of the view in Oracle", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "what is the use of the view in Oracle" this article.
1. What is a view?
A VIEW, also known as a virtual table, is a logical representation of a set of data.
The view corresponds to a SELECT statement, and the result set is given a name, that is, the view name.
The view itself does not contain any data, but is just a query mapped to the base table. When the base table data changes, the view data is sent with it.
Function: reuse code and protect data
two。 Permission GRANT CREATE VIEW TO user scott is required to create a view
CREATE VIEW view_name alias
Not including functions is called simple view
Contains complex views of function expressions
Join views based on multiple tables
OR REPLACE update view replace if present
Grammar
CREATE OR REPLACE VIEW View name SELECT statement
Hide column names add aliases to SELECT statements
CREATE OR REPLACE VIEW v_emp_10 AS SELECT empno id, ename name,sal salary,deptno deptno FROM emp WHERE deptno=10
View view structure DESC view name
After adding aliases, you can only use aliases to query view SELECT name, salary, job FROM v_emp_10.
Add WITH CHECK OPTION to prevent dirty data from being inserted into the base table in simple view mode
CREATE OR REPLACE VIEW v_emp_10 AS SELECT empno id
Ename name,sal salary,deptno deptno FROM emp WHERE deptno=10 WITH CHECK OPTION
Creation of complex views
CREATE VIEW v_emp_salary
AS
SELECT d.dname
AVG (e.sal) avg_sal
SUM (e.sal) sum_sal
MAX (e.sal) max_sal
MIN (e.sal) min_sal
FROM emp e JOIN dept d ON e.deptno = d.deptno GROUP BY d.dname
Query for complex views
SELECT * FROM v_emp_salary
Complex views do not allow DML operations
The above is all the content of the article "what's the use of views in Oracle?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.