T
Tim Parker

Posted on 27th February 2024|33 views

0
votes

Insert Into Postgresql Table

How to use "Insert Into" in the PostgreSQL table?

Answers
P
James ROBERT

Posted on 27th February 2024

  1. Insert into” function is used to add a new record or data to the data table in PostgreSQL DBMS.

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.
 

  1. Using “SELECT” function with “Insert into” to add data to the existing table or new table from another old existing table.

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.

Write your answer

STILL GOT QUERIES?

Get a Live FREE Demo
  • Explore the trending and niche courses and learning maps
  • Learn about tuition fee, payment plans, and scholarships
  • Get access to webinars and self-paced learning videos