Auto Increment (Postgresql) Vs. AutoNumber (MS Access)

In Postgresql, prefer making Auto Increment for the table right from start. Following is code for a test table:

CREATE TABLE test_table(

    test_id SERIAL PRIMARY KEY

);

I wrote above code in pgAdmin 4 >> Tools >> Query Tool

Executing this query straight made the table under Public Schema. Then I altered the table (using graphic interface) and added another text column.

MS Access Autonumber vs. Postgresql Auto Increment

Difference with MS Access is that MS Access assigns autonumber according to sequence by just entering the data into another column. But Postgresql assigns Auto Increment when data of complete row is entered and cursor moves to next row. Since Auto Increment column cannot be null (and is also PRIMARY KEY), so it cannot be blank. Postgresql fills this column when cursor moves to next row (In MS Access linked table). Secondly, in Postgresql, it is possible to explicitly enter any value other than sequence. The same is not the behavior of MS Access. However, explicit entry in this column is to be avoided as it will create problems. For example in fourth row, I explicitly entered number 25. Then next row automatically took the number 4 and it worked up to number 24. Afterwards, auto increment failed for one time and number 26 was entered manually. Then auto increment kept going correctly.

About the author

Leave a Reply

avatar
  Subscribe  
Notify of