psql/create-view

Create View

Create a new PostgreSQL view

view
create

Command

CREATE VIEW viewname AS SELECT column1, column2, ... FROM tablename;

Explanation

Creates a new view in the current database.

Examples

Create view for active users

CREATE VIEW active_users AS SELECT * FROM users WHERE status = 'active';