> For the complete documentation index, see [llms.txt](https://vikram-bajaj.gitbook.io/cs-gy-6083-principles-of-database-systems/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://vikram-bajaj.gitbook.io/cs-gy-6083-principles-of-database-systems/sql/intermediate-sql/views.md).

# Views

A view provides a mechanism to hide certain data from the view of certain users. Any relation that is not in the conceptual model but is made visible to a user as a “virtual relation” is called a view.

A view is defined using the **create view** statement which has the form:

```
create view v as <query expression>
```

where \<query expression> is any legal SQL expression. The view name is represented by v.

Example: A view of instructors without their salary:

```
create view faculty as
select ID, name, dept_name
from instructor
```

Once a view is defined, the view name can be used to refer to the virtual relation that the view generates.

Note that updates made to a view will reflect in the relation from which the view was created. Since the view may not have all attributes of the relation, the remaining attributes will be given null values.

In the above example, if a new record is inserted into the view faculty, a new record will be inserted into instructor as well, but salary will be null.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://vikram-bajaj.gitbook.io/cs-gy-6083-principles-of-database-systems/sql/intermediate-sql/views.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
