I want to create some mad robust code. I want to take a query as a string, create a temporary view / table to store the results, use it, then drop the table. I want to use a name that is guaranteed to not already exist in the database. Is there an SQL command to generate a unique table name? I’m using postgresql if this is implementation-specific.
Share
You could use a temporary table. Temporary tables are invisible to other connections. If a permanent table with the same name as the temporary table exists, the permanent table is invisible to the current connection.
See the PostgreSQL manual page.