是否可以在单独的查询中存在两个具有相同名称的临时表 [英] Can two temporary tables with the same name exist in separate queries

查看:97
本文介绍了是否可以在单独的查询中存在两个具有相同名称的临时表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道,是否有可能在两个单独的查询中有两个名称相同的临时表,而在稍后的查询中调用时它们不会冲突。

I was wondering, if it is possible to have two temp tables with the same name in two separate queries without them conflicting when called upon later in the queries.

查询1:将临时表Tmp1创建为...

Query 1: Create Temp Table Tmp1 as ...

查询2:将临时表Tmp1创建为。 ..

Query 2: Create Temp Table Tmp1 as ...

查询1:使用Tmp1做某事...

Query 1: Do something with Tmp1 ...

我想知道PostgreSQL是否可以区分那些两个表,也许可以通过将它们寻址为Query1.Tmp1和Query2.Tmp1

I am wondering if postgresql distinguishes between those two tables, maybe through addressing them as Query1.Tmp1 and Query2.Tmp1

推荐答案

与数据库的每个连接都有自己的特殊<一个href = https://dba.stackexchange.com/a/76661>临时架构名称,并在该架构中创建临时表。因此,即使表具有相同的名称,来自单独连接的并发查询之间也不会发生任何冲突。 https://dba.stackexchange.com/a/5237 了解更多信息

Each connection to the database gets its own special temporary schema name, and temp tables are created in that schema. So there will not be any conflict between concurrent queries from separate connections, even if the tables have the same names. https://dba.stackexchange.com/a/5237 for more info

用于创建表的 PostgreSQL文档指出:


临时表存在于特殊模式中,因此在创建临时表时无法给出模式名称。

Temporary tables exist in a special schema, so a schema name cannot be given when creating a temporary table.

这篇关于是否可以在单独的查询中存在两个具有相同名称的临时表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆