Select Page

How to get the last inserted id from a sequence in postgresql

Use the currval() sequence function

SELECT currval('my_sequence');

Replace my_sequence with your sequence, remember currval returns the latest value that was obtained from your sequence in your session.

Last Updated On April 07, 2018

Leave a reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.