Oracle中创建视图的语法,没有临时视图这概念
标签:PostgreSQL,temp,database,临时,视图,db03,select,view From: https://www.cnblogs.com/gwgwgw/p/16818733.htmlCREATE [OR REPLACE] [[NO] FORCE] [EDITIONING] VIEW [schema.] view [ ( { alias [ inline_constraint... ] | out_of_line_constraint } [, { alias [ inline_constraint...] | out_of_line_constraint } ] ) | object_view_clause | XMLType_view_clause ] AS subquery [ subquery_restriction_clause ] ;
PostgreSQL中有临时视图,session结束时,视图就会消失
db03=# \h create view
Command: CREATE VIEW
Description: define a new view
Syntax:
CREATE [ OR REPLACE ] [ TEMP | TEMPORARY ] [ RECURSIVE ] VIEW name [ ( column_name [, ...] ) ]
[ WITH ( view_option_name [= view_option_value] [, ... ] ) ]
AS query
[ WITH [ CASCADED | LOCAL ] CHECK OPTION ]测试:
db03=# select pg_backend_pid();
pg_backend_pid
----------------
3043
(1 row)db03=# create temp view temp_view as select * from pg_class;
CREATE VIEW
db03=# select count(*) from temp_view;
count
-------
346
(1 row)db03=# select current_database();
current_database
------------------
db03
(1 row)db03=# \c postgres
You are now connected to database "postgres" as user "postgres".
postgres=# \c db03
You are now connected to database "db03" as user "postgres".
db03=# select current_database();
current_database
------------------
db03
(1 row)db03=# select count(*) from temp_view;
ERROR: relation "temp_view" does not exist
LINE 1: select count(*) from temp_view;
^
db03=# select pg_backend_pid();
pg_backend_pid
----------------
3066
(1 row)