Posted on 28th April 2025|35 views
How to use "Insert Into" in the PostgreSQL table?
Posted on 28th April 2025| views
Syntax:
Insert Into user-details (Column1, Column2, Column3,. . . . . )
Values(Detail1, Detail2, Detail3, . . . . . )
For Example:
INSERT INTO my_personal_info(Customer_name, Fullname, CustomerAddress, City, Country, PostalCode)
VALUES ('Aroni', 'Samyuk. Aroni ', 'Erragada', 'Hyderabad', 'India', '9658');
Customer_name |
Fullname |
CustomerAddress |
City |
Country |
PostalCode |
Aroni |
Samyuk.Aroni |
Erragada |
Hyderabad |
India |
9658 |
Result:
One new record inserted.
Or
Simply, we can define as adding specific data from one table to another table.
The data from the target table is unaffected even if it shares the data with some other table.
Syntax:
For example, let us assume that we need to add data from table1 to table2,
INSERT INTO table2(name, City, Country)
SELECT name, City, Country
FROM table1
WHERE name=’Aroni';
# Assume Aroni name specified on table1 and when we use where we can get the corresponding name, city, country details transferred to table2 from table1.