if multiple users run a query that creates a temp table at the same time, would the data in the table be corrupted in each session? [closed]

dba.stackexchange https://dba.stackexchange.com/questions/283458

Pergunta

I am using postgres12. I have a query that creates a temp table named table_x and returns it. I am wondering if this data will be corrupted since there is multiple users running the same query at the same time, and will all be creating a table with the same name? Would they be editing each others temp table? How does postgres behave in these circumstances?

BTW: The data returned in each temp table is unique to the user making the query.

Also, I have attempted to structure the query like so:

return table (

)

return query;

However, I need the results from multiple return queries to be returned in the table, meaning I would need it to look like:

return table (
)

return query;

return query;

return query;

And I have not found success with this structure so far.

If anyone has advice, it will be greatly appreciated.

Foi útil?

Solução

When you create a temporary table in PostgreSQL, only the connection that created that temp table will be able to access it because it is generated in a unique schema for that connection. This is to avoid the very conflicts you're asking about (by using schema separation). This StackOverflow Answer provides more details regarding this.

You can also read more on the documentation for CREATE TABLE.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a dba.stackexchange
scroll top