Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6927883
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:06:45+00:00 2026-05-27T11:06:45+00:00

I created a temp table in my PostgreSQL DB using the following query SELECT

  • 0

I created a temp table in my PostgreSQL DB using the following query

SELECT * INTO TEMP TABLE tempdata FROM data WHERE id=2004;

Now I want to create a backup of this temp table tempdata.
So i use the following command line execution

"C:\Program Files\PostgreSQL\9.0\bin\pg_dump.exe" -F t -a -U my_admin -t tempdata myDB >"e:\mydump.backup"  

I get a message saying

pg_dump: No matching tables were found  

Is it possible to create a dump of temp tables?
Am I doing it correctly?

P.S. : I would also want to restore the same.I don’t want to use any extra components.

TIA.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T11:06:46+00:00Added an answer on May 27, 2026 at 11:06 am

    I don’t think you’ll be able to use pg_dump for that temporary table. The problem is that temporary tables only exist within the session where they were created:

    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.

    So you’d create the temporary table in one session but pg_dump would be using a different session that doesn’t have your temporary table.

    However, COPY should work:

    COPY moves data between PostgreSQL tables and standard file-system files.

    but you’ll either be copying the data to the standard output or a file on the database server (which requires superuser access):

    COPY with a file name instructs the PostgreSQL server to directly read from or write to a file. The file must be accessible to the server and the name must be specified from the viewpoint of the server.
    […]
    COPY naming a file is only allowed to database superusers, since it allows reading or writing any file that the server has privileges to access.

    So using COPY to dump the temporary table straight to a file might not be an option. You can COPY to the standard output though but how well that will work depends on how you’re accessing the database.

    You might have better luck if you didn’t use temporary tables. You would, of course, have to manage unique table names to avoid conflicts with other sessions and you’d have to take care to ensure that your non-temporary temporary tables were dropped when you were done with them.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The following T/SQL:- create table #temp(foo varchar(10)) insert into #temp select '' insert into
I have written a DB2 query to do the following: Create a temp table
I have a stored procedure that first inserts some data into a temp table
I have a temp table created from a copy from a CSV file and
We have created one temp-table dynamically . and we want to out put the
I am trying to update a #temp table from a linked server using a
Using Informix, I've created a tempory table which I am trying to populate from
I created the global temp table. when I execute the code as an individual
Basically i want to be able to dynamically create a temp table based off
Consider the following table: create table temp ( name int, a int, b int

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.