reset password
Author Message
harry_520
Posts: 76
Posted 20:58 Oct 16, 2013 |

Why do I get an error when I use auto_increment or serial?

Last edited by harry_520 at 11:19 Oct 22, 2013.
cysun
Posts: 2935
Posted 08:08 Oct 24, 2013 |

PostgreSQL does not support the auto_increment keyword. Serial already means auto_increment.

harry_520
Posts: 76
Posted 10:31 Oct 24, 2013 |
cysun wrote:

PostgreSQL does not support the auto_increment keyword. Serial already means auto_increment.

 Dr, Sun. Can you give an example how we use serial? I still don't quite get it.

cysun
Posts: 2935
Posted 10:36 Oct 24, 2013 |
create table test (
    id serial primary key,
    name varchar(255)
);
insert into test (name) values ('Joe');
insert into test (name) values ('Jane');