Introduction
The INSERT with RETURNING clause lets you add new data to a table and immediately get back the inserted rows or specific columns. This saves extra steps.
When you add a new user and want to get their unique ID right away.
When inserting a new order and need to know the order number generated by the database.
When you want to confirm what data was actually saved after an insert.
When you want to insert data and use the returned values in your program without another query.