使用returning
CREATE TABLE users (firstname text, lastname text, id serial
primary key);
INSERT INTO users (firstname, lastname) VALUES ('Joe', 'Cool')
RETURNING id;
INSERT INTO users (firstname, lastname) VALUES ('Frank', 'Ben')
RETURNING id;
delete的时候会把删除的行返回
DELETE from users RETURNING *;