模式(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=#