Friday , April 26 2024

How To Get Data With Insert In PostgreSQL

In this article, we will explain how we can get data from a different table with insert and what we should pay attention to between these tables.

Example:

We have tables named staff and staff_old, among which we will transfer the records from the staff_old table to the staff table, but while doing these, we need to pay attention to the following features.

The columns of the tables must be the same.

The data types of the columns of the tables must be the same.

In the PLPGSQL sentence above, the number of columns between the tables must be equal.

The part specified as Original_Table above is the column where the data is to be transferred.

The table to be copied is the table from which we will get the data.

First, we check our data by selecting both tables.

We listed the data in the personnel table above and we saw that there are 4 data in total.

There are 3 records in the table that we want to transfer to the personnel table.

We transfer them to the other table as follows

We transferred the data to the Personnel table above with insert, let’s verify this by selecting the personnel table.

Loading

About Faruk Erdem

Leave a Reply

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

Categories