---
description: What is PostgreSQL View? In PostgreSQL, a view is a pseudo-table. This means that a view is not a real table. However, we can SELECT it as an ordinary table. A view can have all or some of the table c
title: PostgreSQL Create View with Example
image: https://www.guru99.com/images/postgresql-create-view.png
---

 

[Skip to content](#main) 

**⚡ Smart Summary**

PostgreSQL views are pseudo-tables built from a stored SELECT query, letting you wrap complex or frequently used queries behind a single name that you can read, update, or drop like an ordinary table.

* 🗂️ **Pseudo-Table:** A view stores a query, not data, yet you SELECT it like a table.
* 🛠️ **Create:** CREATE VIEW names a SELECT query, even across several base tables, for easy reuse.
* ♻️ **Replace:** CREATE OR REPLACE VIEW changes a view without dropping it.
* 🗑️ **Drop:** DROP VIEW removes a view, and IF EXISTS avoids an error.
* 🤖 **AI Help:** AI assistants generate view definitions and suggest which queries to wrap.

[ Read More ](javascript:void%280%29;) 

![PostgreSQL Create View](https://www.guru99.com/images/postgresql-create-view.png)

## What is PostgreSQL View?

In [PostgreSQL](https://www.guru99.com/postgresql-tutorial.html), a view is a pseudo-table. This means that a view is not a real table. However, we can SELECT it as an ordinary table. A view can have all or some of the table columns. A view can also be a representation of more than one table.

The tables are referred to as base tables. When creating a view, you just need to create a query then give it a name, making it a useful tool for wrapping complex and commonly used queries.

## Creating PostgreSQL Views

To create a PostgreSQL view, we use the CREATE VIEW statement. Here is the syntax for this statement:

CREATE [OR REPLACE] VIEW view-name AS
  SELECT column(s)
  FROM table(s)
  [WHERE condition(s)];

The OR REPLACE parameter will replace the view if it already exists. If omitted and the view already exists, an error will be returned.

The view-name parameter is the name of the view that you need to create.

The WHERE condition(s) are optional, and they must be satisfied for any record to be added to the view.

Consider the Price table given below:

**Price:**

[](https://www.guru99.com/images/1/102319%5F0654%5FPostgreSQLC1.png)

Let us create a view from the above table:

CREATE VIEW Price_View AS
  SELECT id, price
  FROM Price
  WHERE price > 200;

The above command will create a view based on the [SELECT statement](https://www.guru99.com/postgresql-select-distinct.html). Only the records where the price is greater than 200 will be added to the view. The view has been given the name Price\_View. Let us query it to see its contents:

SELECT *
FROM Price_View;

This returns the following:

[](https://www.guru99.com/images/1/102319%5F0654%5FPostgreSQLC2.png)

Even though the base table has 4 records, only 2 were added to the view.

Here, we can add only one column to the view. Let us create a view that includes only one column of the Price table:

CREATE VIEW Price_View2 AS
  SELECT price
  FROM Price
  WHERE price > 200;

The view has been given the name Price\_View2 and includes only the price column of the Price table. Let us query the view to see its contents:

SELECT *
FROM Price_View2;

This returns the following:

[](https://www.guru99.com/images/1/102319%5F0654%5FPostgreSQLC3.png)

## Changing PostgreSQL Views

The definition of a view can be changed without having to drop it. This is done using the CREATE OR REPLACE VIEW statement.

Let us demonstrate this by updating the view named Price\_View2.

**Price\_View2:**

[](https://www.guru99.com/images/1/102319%5F0654%5FPostgreSQLC4.png)

The Book table is as follows:

**Book:**

[](https://www.guru99.com/images/1/102319%5F0654%5FPostgreSQLC5.png)

The Price table is as follows:

**Price:**

[](https://www.guru99.com/images/1/102319%5F0654%5FPostgreSQLC6.png)

The following query will help us update the view Price\_View2:

CREATE or REPLACE VIEW Price_View2 AS
  SELECT price, name
  FROM Book
  INNER JOIN Price
  ON Book.id = Price.id
  WHERE price > 200;

Let us now query the view to see its contents:

[](https://www.guru99.com/images/1/102319%5F0654%5FPostgreSQLC7.png)

The view has been changed, and now we have two columns from two different tables. This has been achieved using a JOIN statement.

### RELATED ARTICLES

* [PostgreSQL Data Types: Numeric, Character, Byte ](https://www.guru99.com/postgresql-data-types.html "PostgreSQL Data Types: Numeric, Character, Byte")
* [How to Create Database in PostgreSQL ](https://www.guru99.com/postgresql-create-database.html "How to Create Database in PostgreSQL")
* [PostgreSQL SUBSTRING() Function with Regex Example ](https://www.guru99.com/postgresql-substring.html "PostgreSQL SUBSTRING() Function with Regex Example")
* [PostgreSQL BETWEEN Query with Example ](https://www.guru99.com/postgresql-between.html "PostgreSQL BETWEEN Query with Example")

## Deleting PostgreSQL Views

Anytime you need to delete a PostgreSQL view, you can use the DROP VIEW statement. Here is the syntax for the statement:

DROP VIEW [IF EXISTS] view-name;

The parameter view-name is the name of the view that is to be deleted.

In this syntax, IF EXISTS is optional. If you do not specify it and attempt to delete a view that does not exist, you will get an error.

For example, to drop the view named Price\_View2, we can run the following statement:

DROP VIEW Price_View2;

The view will be deleted.

## Using pgAdmin

Now let us see how these actions can be performed using pgAdmin.

### Creating PostgreSQL Views

To accomplish the same through pgAdmin, do this:

**Step 1)** Login to your pgAdmin account.

**Step 2)**

* From the navigation bar on the left- Click Databases.
* Click Demo.

[](https://www.guru99.com/images/1/102319%5F0654%5FPostgreSQLC8.png)

**Step 3)** Type the query in the query editor:

CREATE VIEW Price_View AS
  SELECT id, price
  FROM Price
  WHERE price > 200;

**Step 4)** Click the Execute button.

[](https://www.guru99.com/images/1/102319%5F0654%5FPostgreSQLC9.png)

**Step 5)** To view the contents of the view, do the following:

* Type the following command in the query editor:

SELECT *
FROM Price_View;

* Click the Execute button.

[](https://www.guru99.com/images/1/102319%5F0654%5FPostgreSQLC10.png)

This will return the following:

[](https://www.guru99.com/images/1/102319%5F0654%5FPostgreSQLC11.png)

To create the view Price\_View2, do the following:

**Step 1)** Type the following query in the query editor:

CREATE VIEW Price_View2 AS
  SELECT price
  FROM Price
  WHERE price > 200;

**Step 2)** Click the Execute button.

[](https://www.guru99.com/images/1/102319%5F0654%5FPostgreSQLC12.png)

**Step 3)** To see the contents of the view, do the following:

* Type the following query in the query editor:

SELECT *
FROM Price_View2;

* Click the Execute button.

[](https://www.guru99.com/images/1/102319%5F0654%5FPostgreSQLC13.png)

This will return the following:

[](https://www.guru99.com/images/1/102319%5F0654%5FPostgreSQLC14.png)

### Changing PostgreSQL Views

To accomplish the same through pgAdmin, do this:

**Step 1)** Login to your pgAdmin account.

**Step 2)**

* From the navigation bar on the left- Click Databases.
* Click Demo.

[](https://www.guru99.com/images/1/102319%5F0654%5FPostgreSQLC15.png)

**Step 3)** Type the query in the query editor:

CREATE or REPLACE VIEW Price_View2 AS
  SELECT price, name
  FROM Book
  INNER JOIN Price
  ON Book.id = Price.id
  WHERE price > 200;

**Step 4)** Click the Execute button.

[](https://www.guru99.com/images/1/102319%5F0654%5FPostgreSQLC16.png)

**Step 5)** Type the following query in the query editor:

SELECT *
FROM Price_View2;

This will return the following:

[](https://www.guru99.com/images/1/102319%5F0654%5FPostgreSQLC17.png)

### Deleting PostgreSQL Views

To accomplish the same through pgAdmin, do this:

**Step 1)** Login to your pgAdmin account.

**Step 2)**

* From the navigation bar on the left- Click Databases.
* Click Demo.

[](https://www.guru99.com/images/1/102319%5F0654%5FPostgreSQLC18.png)

**Step 3)** Type the query in the query editor:

DROP VIEW Price_View2;

**Step 4)** Click the Execute button.

[](https://www.guru99.com/images/1/102319%5F0654%5FPostgreSQLC19.png)

The view will be deleted.

[ Download the Database used in this Tutorial](https://drive.google.com/uc?export=download&id=1BqQSvYTmNz4hvZok7iYG9ha%5Fo48%5FVF2b)

## FAQs

🗂️ What is the difference between a view and a table in PostgreSQL?

A table physically stores data on disk. A view stores only a SELECT query, so querying it re-runs that query and returns current data from the base tables.

📸 What is a materialized view in PostgreSQL?

A materialized view caches a query result on disk. It reads faster than a plain view but needs REFRESH MATERIALIZED VIEW to show new data.

⚖️ What is the difference between a view and a materialized view?

A standard view runs its query every time, showing live data. A materialized view stores results on disk for speed but can be stale until refreshed.

✏️ Can you update data through a PostgreSQL view?

Sometimes. A simple single-table view without aggregation is automatically updatable, so INSERT, UPDATE, and DELETE work directly. Complex views need INSTEAD OF triggers.

📋 How do you list all views in a PostgreSQL database?

Query the catalog: SELECT table\_name FROM information\_schema.views WHERE table\_schema = ‘public’. In pgAdmin, you can expand the Views node under a schema.

🤖 How can AI help create PostgreSQL views?

AI assistants turn a plain-language request into a CREATE VIEW statement, name the view, and add the right WHERE and JOIN clauses, speeding up queries you reuse often.

🧠 Can AI convert a complex query into a view?

Yes. Paste a long SELECT and an AI assistant wraps it in CREATE OR REPLACE VIEW, suggests a name, and flags columns needing aliases to avoid duplicate names.

🚀 Do PostgreSQL views improve query performance?

A normal view does not speed up queries because its SELECT runs every time. For faster repeated reads, use a materialized view, which stores results on disk until refreshed.

#### Summarize this post with:

ChatGPT Perplexity Grok Google AI 

**Stay Updated on AI** **Get Weekly AI Skills, Trends, Actionable Advice.** 

##### Sign up for the newsletter

Subscribe for Free 

You have successfully subscribed.  
Please check your inbox. 

![AI-Newsletter]() Chosen by over **350,000+** professionals 

[Scroll to top ](#wrapper)Scroll to top 

× 

Toggle Menu Close 

Search for: 

Search

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://www.guru99.com/#organization","name":"Guru99","sameAs":["https://www.facebook.com/Guru99Official","https://twitter.com/guru99com"],"logo":{"@type":"ImageObject","@id":"https://www.guru99.com/#logo","url":"https://www.guru99.com/images/guru99-logo-v1-150x59.png","contentUrl":"https://www.guru99.com/images/guru99-logo-v1-150x59.png","caption":"Guru99","inLanguage":"en-US"}},{"@type":"WebSite","@id":"https://www.guru99.com/#website","url":"https://www.guru99.com","name":"Guru99","publisher":{"@id":"https://www.guru99.com/#organization"},"inLanguage":"en-US"},{"@type":"ImageObject","@id":"https://www.guru99.com/images/postgresql-create-view.png","url":"https://www.guru99.com/images/postgresql-create-view.png","width":"700","height":"250","caption":"PostgreSQL Create View","inLanguage":"en-US"},{"@type":"BreadcrumbList","@id":"https://www.guru99.com/postgresql-view.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":"1","item":{"@id":"https://www.guru99.com","name":"Home"}},{"@type":"ListItem","position":"2","item":{"@id":"https://www.guru99.com/postgresql","name":"PostgreSQL"}},{"@type":"ListItem","position":"3","item":{"@id":"https://www.guru99.com/postgresql-view.html","name":"PostgreSQL Create View with Example"}}]},{"@type":"WebPage","@id":"https://www.guru99.com/postgresql-view.html#webpage","url":"https://www.guru99.com/postgresql-view.html","name":"PostgreSQL Create View with Example","dateModified":"2026-07-02T12:15:39+05:30","isPartOf":{"@id":"https://www.guru99.com/#website"},"primaryImageOfPage":{"@id":"https://www.guru99.com/images/postgresql-create-view.png"},"inLanguage":"en-US","breadcrumb":{"@id":"https://www.guru99.com/postgresql-view.html#breadcrumb"}},{"@type":"Person","@id":"https://www.guru99.com/author/juniper","name":"Juniper Willow","description":"I am Juniper Willow, a PostgreSQL Developer, offering expert guidance to help you optimize and master PostgreSQL database development.","url":"https://www.guru99.com/author/juniper","image":{"@type":"ImageObject","@id":"https://www.guru99.com/images/juniper-willow-author.png","url":"https://www.guru99.com/images/juniper-willow-author.png","caption":"Juniper Willow","inLanguage":"en-US"},"worksFor":{"@id":"https://www.guru99.com/#organization"}},{"articleSection":"PostgreSQL","headline":"PostgreSQL Create View with Example","description":"What is PostgreSQL View? In PostgreSQL, a view is a pseudo-table. This means that a view is not a real table. However, we can SELECT it as an ordinary table. A view can have all or some of the table c","keywords":"postgresql, sql","speakable":{"@type":"SpeakableSpecification","cssSelector":[".entry-title",".summary"]},"@type":"Article","author":{"@id":"https://www.guru99.com/author/juniper","name":"Juniper Willow"},"dateModified":"2026-07-02T12:15:39+05:30","image":{"@id":"https://www.guru99.com/images/postgresql-create-view.png"},"copyrightYear":"2026","name":"PostgreSQL Create View with Example","subjectOf":[{"@type":"FAQPage","mainEntity":[{"@type":"Question","name":"What is the difference between a view and a table in PostgreSQL?","acceptedAnswer":{"@type":"Answer","text":"A table physically stores data on disk. A view stores only a SELECT query, so querying it re-runs that query and returns current data from the base tables."}},{"@type":"Question","name":"What is a materialized view in PostgreSQL?","acceptedAnswer":{"@type":"Answer","text":"A materialized view caches a query result on disk. It reads faster than a plain view but needs REFRESH MATERIALIZED VIEW to show new data."}},{"@type":"Question","name":"What is the difference between a view and a materialized view?","acceptedAnswer":{"@type":"Answer","text":"A standard view runs its query every time, showing live data. A materialized view stores results on disk for speed but can be stale until refreshed."}},{"@type":"Question","name":"Can you update data through a PostgreSQL view?","acceptedAnswer":{"@type":"Answer","text":"Sometimes. A simple single-table view without aggregation is automatically updatable, so INSERT, UPDATE, and DELETE work directly. Complex views need INSTEAD OF triggers."}},{"@type":"Question","name":"How do you list all views in a PostgreSQL database?","acceptedAnswer":{"@type":"Answer","text":"Query the catalog: SELECT table_name FROM information_schema.views WHERE table_schema = 'public'. In pgAdmin, you can expand the Views node under a schema."}},{"@type":"Question","name":"How can AI help create PostgreSQL views?","acceptedAnswer":{"@type":"Answer","text":"AI assistants turn a plain-language request into a CREATE VIEW statement, name the view, and add the right WHERE and JOIN clauses, speeding up queries you reuse often."}},{"@type":"Question","name":"Can AI convert a complex query into a view?","acceptedAnswer":{"@type":"Answer","text":"Yes. Paste a long SELECT and an AI assistant wraps it in CREATE OR REPLACE VIEW, suggests a name, and flags columns needing aliases to avoid duplicate names."}},{"@type":"Question","name":"Do PostgreSQL views improve query performance?","acceptedAnswer":{"@type":"Answer","text":"A normal view does not speed up queries because its SELECT runs every time. For faster repeated reads, use a materialized view, which stores results on disk until refreshed."}}]}],"@id":"https://www.guru99.com/postgresql-view.html#schema-1128985","isPartOf":{"@id":"https://www.guru99.com/postgresql-view.html#webpage"},"publisher":{"@id":"https://www.guru99.com/#organization"},"inLanguage":"en-US","mainEntityOfPage":{"@id":"https://www.guru99.com/postgresql-view.html#webpage"}}]}
```
