Databases · Junior · Question 61 of 75

What does INSERT ... RETURNING id do in PostgreSQL?

Explanation

It saves a round trip and avoids race conditions of 'insert, then select the max id'. RETURNING also works with UPDATE and DELETE.

Further reading

Problem with a question

Databases · Junior · question 61

Test yourself

Take the Databases · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz