配置访问模式的顺序 本文为您介绍如何配置访问模式的顺序。 TeleDB有一个运行变量叫searchpath,其值为模式名列表,用于配置访问数据对象的顺序,如下所示。 当前连接用户。 plaintext teledb select currentuser; currentuser teledb (1 row) 显示当前searchpath,搜索路径只配置为$user , public,其中 $user 为当前用户名,即上面的currentuser 值teledb 。 plaintext teledb show searchpath; searchpath "$user", public (1 row) 不指定模式创建数据表,则该表存放于第一个搜索模式下面。第一个模式找不到的情况下选择第二个,依次顺序查找。 plaintext teledb create table t2(id int, content text); CREATE TABLE teledb dt t2 List of relations Schema Name Type Owner +++ public t2 table teledb (1 row) 由于没有teledb模式,所以表默认放到了public模式下 创建teledb模式后再次建表,表建到了teledb模式下 teledb create schema teledb; CREATE SCHEMA teledb create table t3(id int, content text); CREATE TABLE teledb dt t3 List of relations Schema Name Type Owner +++ teledb t3 table teledb (1 row) 指定表位于某个模式下,不同模式下表名可以相同。在public模式下创建t3表 plaintext teledb create table public.t3(id int, content text); CREATE TABLE teledb dt public.t3 List of relations Schema Name Type Owner +++ public t3 table teledb (1 row) 同名的表查询时,没有指定shema时,始终只会查到前面模式的表数据。 plaintext 插入数据到public.t3表 teledb