Reputation: 307
I'm trying to get the last value of a sequence in my database, and acording to what i found, the query should be done like this: SELECT last_value FROM my_sequence
. However, when i hit enter, the only thing I get in the console is:
ERROR: relation "my_sequence" does not exist
LINE 1: select last_value from my_sequence;
^
Any help?
Edit: the sequence does exist, for I do get the name of it when I list all sequences
Upvotes: 1
Views: 494
Reputation: 23686
You have to define the schema you are using:
SELECT last_value FROM my_schema.my_sequence
Upvotes: 1
Reputation: 1460
Try this :
select currval('my_sequence')
OR
select currval('my_schema.my_sequence')
Upvotes: 1