好好爱自己!

postgreSqL的序列sequence

PostgreSQL uses sequences to generate values for serial columns and serial columns are generally what is used for "auto-incrementing" columns in PostgreSQL. Sequences have names and are, in general, independent of any particular table so you could have one sequence generating unique IDs for several different tables; the sequence name is what lastInsertId wants as its argument:

For example, PDO_PGSQL() requires you to specify the name of a sequence object for the name parameter.

The sequence object created by PostgreSQL is automatically named [table]_[column]_seq, So:

$id = $db->lastInsertId('tableName_columnName_seq');

reference: http://stackoverflow.com/questions/10492566/lastinsertid-does-not-work-in-postgresql
posted @ 2016-12-25 19:45  立志做一个好的程序员  阅读(938)  评论(0编辑  收藏  举报

不断学习创作,与自己快乐相处