国内最全IT社区平台 联系我们 | 收藏本站
华晨云阿里云优惠2
您当前位置:首页 > 数据库 > 数据库应用 > PostgreSQL学习篇10.1 模式

PostgreSQL学习篇10.1 模式

来源:程序员人生   发布时间:2017-02-21 08:22:09 阅读次数:4563次
模式(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=#

 

生活不易,码农辛苦
如果您觉得本网站对您的学习有所帮助,可以手机扫描二维码进行捐赠
程序员人生
------分隔线----------------------------
分享到:
------分隔线----------------------------
关闭
程序员人生