RETURNING clause

INSERT, UPDATE and DELETE have option RETURNING clause that returns the row that is inserted, updated or deleted.

Syntax

INSERT INTO table_name(column_list)
VALES(values_list)
RETURNING
    expression1 as column_alias1
    expression2 as column_alias2
	...;

If you want to return all columns, use the asterisk * shortcut:

INSERT INTO table_name(column_list)
VALES(values_list)
RETURNING *;

Example

INSERT INTO table_name(title, isbn, release_date)
VALES('The Catcher in the Rye', '7162374623', '1951-07-16')
RETURNING *;

INSERT INTO table_name(title, isbn, release_date)
VALES('The Catcher in the Rye', '7162374623', '1951-07-16')
RETURNING id;

INSERT INTO table_name(title, isbn, release_date)
VALES('The Catcher in the Rye', '7162374623', '1951-07-16')
RETURNING 
  id AS book_id,
  strftime('%Y', release_date) AS year;
const row = db.queryOne("INSERT INTO user (github_id, email, username) VALUES (?, ?, ?) RETURNING user.id", [
        githubId,
        email,
        username
	]);