Wednesday , May 29 2024

How To Move a Table On PostgreSQL


Sometimes we may want to create the same table in a database without the data in it by using a different name or we want to create the table with a different name with the data.

There are several methods for this.

In this article, we will do the move operation by creating a new table with data and without data.

Let’s connect to the database and see the table we’re copying.


You can use the following command to create the table above with a different name in the same database without data.


After running the above command, when we check with command “\dt+” we see that it was created without data in it.


We can use the following command to copy the table with the data.

The table was transferred with the data.

In addition, we can create a new table by taking part of the records in the table.


As shown below, our table named d1_condition has been created.


About Faruk Erdem

Leave a Reply

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