UPDATE, DELETE, RETURNING

SELECT * FROM author;

UPDATE author
SET full_name = 'Sem', rating = 5
WHERE author_id = 1;
-- Delete some
DELETE FROM author
WHERE rating < 4.5

-- Delete all. Create logs
DELETE FROM author;

-- Delete all. Don't create logs
TRUNCATE TABLE author;
-- Return inserted value with all fields
INSERT INTO book (title, isbn, publisher_id)
VALUES ('title', 'isbn', 3)
RETURNING *;

Last updated

Was this helpful?