Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Postgresql equivalent of an Access autonumber field

I am trying to build a database for my company and my programmer does not know how to have a number which fills itself in like in Access 2003. In Access, you can have auto number with a field and it will insert for you. How do you do this in Postgresql? My programmer needs help, and he cannot find a book on it. Thanks very much!

like image 904
nekroblivion Avatar asked Sep 01 '25 23:09

nekroblivion


1 Answers

Postgresql documentation: 8.1.4. Serial Types

CREATE TABLE tablename (
    colname SERIAL
);

The data types serial and bigserial are not true types, but merely a notational convenience for creating unique identifier columns (similar to the AUTO_INCREMENT property supported by some other databases).

like image 56
j.w.r Avatar answered Sep 03 '25 20:09

j.w.r