0

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.

0

documentation means:

  • if you have permanent table TABLE_A
  • and you create a temporary table with the same name TABLE_A,

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.