0

I have a large application that connects to SQL Server and makes extensive use of temporary tables using the #table syntax. I would like to convert this to connect to postgres, which does not accept that notation. Is there a work-around, other than modifying all my code?

0

Postgres supports temporary tables but it does not support the #tablename syntax. You can keep the structure but you will have to modify the code to the new syntax. Unless you want to download the code for Postgres and modify that but that seems like unrecommended overkill.

http://www.sqlines.com/postgresql/statements/create_temporary_table

CREATE TEMPORARY TABLE statement creates a temporary table that is automatically dropped at the end of a session, or the current transaction (ON COMMIT DROP option).

Quick Example:

   -- Create a temporary table
   CREATE TEMPORARY TABLE temp_location
   (
      city VARCHAR(80),
      street VARCHAR(80)
   ) 
   ON COMMIT DELETE ROWS;

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.