Search Postgresql Archives

Re: serial autoincrement and related table

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




> If you want PostgreSQL to populate your idmember field with the next > value from the sequence, you need to specify the keyword DEFAULT as its > value or omit it from the INSERT list of coulumns (this assumes you have

I do omit it.

> DEFAULT nextval('members_idmember_seq') defined on the idmember column).

I use CREATE TABLE "members" (idmember" SERIAL PRIMARY KEY, ...);

> Should be :
>
> Cmd = "SELECT currval('members_idmember_seq');"

Ah, thanks for the shorter syntax.

> Remember that there's no such thing as auto-increment fields in
> PostgreSQL - they are SEQUENCES.

I know.

So, it's the best or reasonable practice(TM), isn't it?

--
Milos Prudek


---------------------------(end of broadcast)--------------------------- TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux