Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2010
    Posts
    4

    Unanswered: How ta make a temporary table global in PostgreSQL

    Hi,
    I want to insert data into a temp table and then through JDBC I want to access the data of the temp table at different occasions (pagination). But I am unable to make the temp table global.i.e. to make it available to all sessions whenever needed.
    I looked into it but found that " Although the syntax of CREATE TEMPORARY TABLE resembles that of the SQL standard, the effect is not the same. In the standard, temporary tables are defined just once and automatically exist (starting with empty contents) in every session that needs them. PostgreSQL instead requires each session to issue its own CREATE TEMPORARY TABLE command for each temporary table to be used. This allows different sessions to use the same temporary table name for different purposes, whereas the standard's approach constrains all instances of a given temporary table name to have the same table structure. The standard's definition of the behavior of temporary tables is widely ignored. PostgreSQL's behavior on this point is similar to that of several other SQL databases. ".

    So can anyone help me as how to make a temp table available to all sessions whenever needed?

  2. #2
    Join Date
    Aug 2009
    Location
    Olympia, WA
    Posts
    337
    Yeah Postgres doesn't have global temp tables. All temp tables will be accessible only to that session and will be deleted when that session is closed. You can have the GLOBAL key word in your create statement but it will be silently ignored.

    You'll need to come up with another solution. Probably a regular table and a job that deletes entries after a certain age.

    See here:
    PostgreSQL: Documentation: Manuals: PostgreSQL 8.1: CREATE TABLE

  3. #3
    Join Date
    Oct 2010
    Posts
    4
    Yeah,
    I solved it with a regular table and a java scheduler to delete the table after a day.

    Thanks anyway.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •