Select to view content in your preferred language

need help troubleshooting a sequential error

07-18-2018 12:18 PM
New Contributor II

hi all, 

i attached a snip of the error that keeps appearing inside of pg_admin. i need the record number(number on far left gray tab)  to match with the gid (PKEY) (i.e. 67 to match with 67, 68 with 68, 69 with 69, etc. )? i have over 20,000 records so going through each record  and changing them one by one will be tiresome.  How do you completely reset the gid into sequential order to match the number in the grayed area?

thanks GJ

0 Kudos
2 Replies
Occasional Contributor III

First off, why do you need to do that?  The far left number is dynamic and will change every time you query the records.  It is about the same as a line number in a text document.  You make a change to the text document and the line numbers will not match up.  Same with that far left number.  Delete a row and that number will no longer line up. Or if you sort by a different column, they won't line up either.

Now if you need the gid in a different order, you should add sort by clause to your SQL statement.

SELECT * FROM schema.tablename  ORDER BY gid ASC/DESC

0 Kudos
MVP Esteemed Contributor

Can you include the headers in your screenshot so we know which columns are which?

I haven't worked with PgAdmin in a long time; but if my memory serves me, the far left column you are talking about isn't part of the table itself, it is just an enumeration of the rows returned by the query.  If you use a different query, like inserting an ORDER BY clause, on the same data, the "first" record will be different than before.

Are you missing a '68' for a PKEY value or is it just not being retrieved sequentially in the viewer you are using?

0 Kudos