Blogging since 2008 until 2010

An easier way to get PostgreSQL sequence names

I got owned. OK, not owned exactly... But reminded of my nooby-ness. Reddit user Thristian99 gave me a much simpler solution to finding out the name of a sequence...

select pg_get_serial_sequence('tablename', 'fieldname');

That's a whole lot nicer :-) I did think it nice to know how the names are actually handled, though - and it only works if the tables / sequences have already been created, of course.

First posted: Thu, 08 Jan 2009 22:11:01 +0000