Search⌘ K

Solution Review: Data Manipulation

Explore how to manipulate data in PostgreSQL through hands-on examples of insert, update, and delete queries. Understand how to use the returning clause to output affected records and apply these operations effectively within your database management.

In the challenge, you were asked to perform three tasks. Here we’re going to discuss the solution to these three tasks.

Task 1

Write a query that inserts the data into the table.

Solution

You were asked to write a query to insert data into the table.

The solution for the challenge is given below. Click the “Run” button in the following widget to see the output of the code.

PostgreSQL
/********************************************************/
/***** Write a query that *****/
/***** inserts the data into the table *****/
/********************************************************/
insert into Employee
values (201, 'Jason', 37000, 'Washington'),
(202, 'Sara', 40000, 'Austin'),
(203, 'Justin', 32000, 'New York'),
(204, 'Lily', 60000, 'San Francisco'),
(205, 'Bean', 45000, 'Chicago'),
(206, 'Ben', 70000, 'Austin')
returning Employee.*;
/********************************************************/

Explanation

The explanation for the task is given below:

  • Line 5: The
...