PostgreSQL學習篇10.1 模式
來源:程序員人生 發布時間:2017-02-21 08:22:09 閱讀次數:5721次
模式(schema)是數據庫中的1個概念,可以將其理解為1個命名空間或目錄。
在PG中,1個數據庫包括1個或多個模式,模式中又包括了表、函數及操作符等數據庫對象。
在PG中,不能同時訪問不同數據庫中的對象,當要訪問另外一個數據庫中的表或其他對象時,需要重新連接到這個新的數據庫,而模式沒有此限制。
模式創建:
create schema sch_name [authorization user_name]
postgres=# create schema test;
CREATE SCHEMA
postgres=# \dn
List of schemas
Name | Owner
--------+----------
public | postgres
test | postgres
(2 rows)
postgres=# drop schema test;
DROP SCHEMA
postgres=# \dn
List of schemas
Name | Owner
--------+----------
public | postgres
(1 row)
postgres=#
postgres=# show search_path;
search_path
-----------------
"$user", public
(1 row)
postgres=#
生活不易,碼農辛苦
如果您覺得本網站對您的學習有所幫助,可以手機掃描二維碼進行捐贈