How-To: Increment Selected Values Inside Insert Statement

SQL programming SQL snippets sql magic

Welcome to my first snippet addition to this website. I hope you find this as helpful as I find it sometimes. Why would I need this? Imagine you want to fill a field of a table with a sequenctially value, but do not have any ID for a sequence and are using PostgreSQL, and you also already have information in this table that you want to append on. Well there is this option to use the internal ID (CID) provided by PostgreSQL, but this only works to a certain extent.