PostgreSQL学习篇10.1 模式

模式(schema)是数据库中的一个概念,可以将其理解为一个命名空间或目录。
在PG中,一个数据库包含一个或者多个模式,模式中又包含了表、函数及操作符等数据库对象。
在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=#

 

相关文章

项目需要,有个数据需要导入,拿到手一开始以为是mysql,结果...
本文小编为大家详细介绍“怎么查看PostgreSQL数据库中所有表...
错误现象问题原因这是在远程连接时pg_hba.conf文件没有配置正...
因本地资源有限,在公共测试环境搭建了PGsql环境,从数据库本...
wamp 环境 这个提示就是说你的版本低于10了。 先打印ph...
psycopg2.OperationalError: SSL SYSCALL error: EOF detect...