Friday , November 22 2024

PostgreSQL Temporary Table

In today’s article, What is a PostgreSQL Temporary Table? and How to Create? We will inform you about the subject.

Most of the things I explained about the table are also valid here, but the Temp(temporary) table is session-based, so you opened the query window to write a query and created the table there, but if you need this temp table again in a different session, you cannot access it and your temp table will be deleted when you close the session.

Temp tables are written to the default tablespace of the created database.

Let’s create a temporary table and perform operations on it.

We created the Temp Table and let’s add data to it

Let’s check if this is the data we added.

As we can see, the data has been added to our temp table.

Let’s query using the \dt command that PostgreSQL created for convenience.

We see above that it is written as pg_temp_3 under the schema.

When we want to delete the table, we can end the session or delete the table with the help of the following command.

Loading

About Faruk Erdem

Leave a Reply

Your email address will not be published. Required fields are marked *