뷰는 여러 테이블(혹은 하나)에서 원하는 값을 따로 뽑은(?) 가상의 테이블이라고 하는데.. 하나의 DB객체이다. 그러면 DB에는 어떤 식으로 저장이 되어있는가..

updatable view 같은 경우 view에서 데이터 변경하면 반영되는 거 보면 참조하는 느낌이긴 한데..

ChatGPT answer

what is "view" exactly in Oracle? i mean physically how the object "view" instored in DB

In Oracle, a "view" is a database object that is used to present data from one or more tables or other views in a structured way. A view is essentially a virtual table that does not store any data on its own, but instead retrieves data from its underlying tables or views at runtime.

Physically, a view is stored as metadata in the data dictionary of the Oracle database, which is a collection of tables and views that describe the structure of the database. The metadata for a view includes information such as the view's name, the SQL query that defines the view, and the names and data types of the columns in the view.

When a user queries a view, Oracle retrieves the view's metadata and the query that defines the view, then generates a temporary result set based on the data in the underlying tables or views. This result set is then returned to the user as if it were a table. Since the view is not a physical table, any changes made to the underlying tables or views will be reflected in the view's result set, providing a flexible and dynamic way to present data to users.

[](data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%2730%27%20height=%2730%27/%3e)

so can i think "view" as a storage of sql query? so i can use that sql query not by rewrite queries, by calling view?

Yes, you can think of a view as a stored SQL query. When you create a view in Oracle, you provide a SQL query that defines the view's columns, data types, and criteria for selecting and filtering data. Once the view is created, you can use it in your SQL queries just like you would use a table.

Using a view can have several benefits. For example, it can simplify complex SQL queries by abstracting away the details of the underlying tables or views. It can also help enforce data security by restricting access to certain columns or rows of data. Additionally, views can improve query performance by pre-computing results or by using indexes on the underlying tables.

When you query a view, Oracle automatically translates the view's SQL query into an execution plan that retrieves data from the underlying tables or views. This means that you don't need to rewrite the SQL query every time you want to retrieve the same data - you can simply query the view.

However, it's important to note that views do not store any data themselves - they only provide a virtual representation of the data in the underlying tables or views. So any modifications to the data must be made through the underlying tables or views, not through the view itself.

[](data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%2730%27%20height=%2730%27/%3e)

as you said lately, if "view" is just a stored sql query, how can I modify data of view's underlying table by modifying view

You cannot modify data in a view directly, because a view is just a virtual representation of the data in one or more underlying tables or views. When you modify data in a view, the changes are actually made to the underlying tables or views that the view is based on.

To modify data in a view's underlying table, you need to modify the data in the table directly, using SQL statements such as UPDATE, INSERT, or DELETE. The changes you make to the underlying table will then be reflected in the view, because the view retrieves its data from the underlying table.

However, it's important to note that not all views are updatable. Whether a view is updatable or not depends on several factors, such as the complexity of the view's SQL query, the presence of aggregation functions or GROUP BY clauses, and the availability of unique indexes or primary keys in the underlying tables. In general, views that are based on simple SQL queries with a one-to-one mapping to a single underlying table are more likely to be updatable.