Fixing sequence problems in PostgreSQL

Is caused by a table with an automatically incremented primary key (set up using the SERIAL keywords in the table creation statement) getting out of sync somehow with the sequence that tracks the next available primary key. You can re-sync the sequence with the following query: