Using postgreSQL 10 or 11, would it be safe creating temporary tables with the same name, each carrying different data? I do not intend to share the data between any sessions/connection/transactions. The name itself is not important, but I would like to safe myself the trouble of generating random names for every concurrent query that needs such intermediate table.
Temporary table is only used in different SELECT
queries. It will be dropped at the end of each transaction with the ON COMMIT DROP
clause.
PostgreSQL documentation states:
Existing permanent tables with the same name are not visible to the current session while the temporary table exists, unless they are referenced with schema-qualified names.
It is not clear to me if this applies to temporary tables too.
Best Answer
documentation means:
a permanent table will be not visible for your code.
But you could request data from the permanent table by add schema to name - schema_name.table_name.
Answering to your question - yes, it is safe.