Defined
First, create a view
1. Syntax create [or replace] [temp | Temporary] View name [(column_name [,...])] As query
2. Example: Create a view that can hide password:
postgres=# CREATE table users (ID int,user_name varchar (+), password varchar (n), user_email text,user_mark text); postgres=# CREATE View vw_users as select Id,user_name,user_email,user_mark from users; CREATE VIEW
3, you can also use the temp or temporary keyword to create a view, when the session ends, the view disappears:
postgres=# Create temp View vw_users as select Id,user_name,user_email,user_mark from users; CREATE viewpostgres=# INSERT INTO users values (1, ' A ', ' 123455 ', ' [email protected] '); Insert 0 1
\q exits and disappears after landing.
4. The view can also define another name for each column of the query. column names, such as the ID, user_name, user_email, User_mark, etc. in the original table, are redefined as no, name, email, Mark,
postgres=# CREATE View Vm_users (No,name,email,mark) as select id,user_name,postgres-# User_email,user_mark from users; CREATE viewpostgres=# SELECT * from Vm_users; No | name | Email | Mark----+------+--------------+------ 1 | a | [Email protected] | (1 row) postgres=#
Second, can update the view
PostgreSQL Logical Structure-view (v)