Skip to content

PostgreSQL pg_is_other_temp_schema() 函数 ​

PostgreSQL pg_is_other_temp_schema() 函数检查指定的 OID 是否是另一个会话的临时模式(Schema)的 OID。

pg_is_other_temp_schema() 语法 ​

这里是 PostgreSQL pg_is_other_temp_schema() 函数的语法:

sql
pg_is_other_temp_schema(oid) -> oid

参数 ​

  • oid

    待检查的 OID。

返回值 ​

PostgreSQL pg_is_other_temp_schema() 函数检查指定的 OID 是否是另一个会话的临时模式(Schema)的 OID,并返回 TRUE 或者 FALSE。

pg_is_other_temp_schema() 示例 ​

首先,让我们通过以下语句创建一个临时表:

sql
CREATE TEMPORARY TABLE test (id INT);

然后,查看当前会话的临时模式(Schema)的 OID:

sql
SELECT pg_my_temp_schema();
bash
 pg_my_temp_schema
-------------------
             17380

在当前会话中,我们使用 pg_is_other_temp_schema() 检查 OID 17380 是否是其他会话的临时模式(Schema)的 OID:

sql
SELECT pg_is_other_temp_schema(17380);
bash
 pg_is_other_temp_schema
-------------------------
 f

这里, pg_is_other_temp_schema() 函数返回了 f (FALSE)。因为 17380 是当前会话的临时模式(Schema)的 OID,而不是其他会话的临时模式(Schema)的 OID。

让我们重新开启一个会话,在执行 pg_is_other_temp_schema() 函数:

sql
SELECT pg_is_other_temp_schema(17380);
bash
 pg_is_other_temp_schema
-------------------------
 t