primary key sequence does not exist
<p>I have a postgresql database and after migrating to a newer version and importing my old data I have a problem with the primary key:</p>

<pre><code>org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint   
"browser_link_pkey"  Detail: Key (id)=(173) already exists.
</code></pre>

<p>So I wanted to reset my sequence, but running:</p>

<pre><code>select nextval('browser_link_id_seq')
</code></pre>

<p>Also fails with:</p>

<pre><code>column „browser_link_id_seq“ does not exist
SQL Status:42703
</code></pre>

<p>This is the SQL for table creation</p>

<pre><code>CREATE TABLE browser_link (
    id bigint NOT NULL,
....
);
ALTER TABLE ONLY browser_link
ADD CONSTRAINT browser_link_pkey PRIMARY KEY (id);
</code></pre>

<p>I tried selecting the serial sequence, but it seems none exists:</p>

<pre><code>postgres=# \connect historify
You are now connected to database "historify" as user "postgres".
historify=# select pg_get_serial_sequence('browser_link', 'id');
 pg_get_serial_sequence
------------------------

(1 row)
</code></pre>

<p>I am using postgresql 9.5.3. Also, until the error occured the id column did increment as expected, so somehow it does work.</p>

<p>Now my two questions:</p>

<ol>
<li>why does the autoincrement work?</li>
<li>how do I reset the autoincrement counter?</li>
</ol>