postgreSqL的序列sequence

Posted 牛顿的小脑

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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


以上是关于postgreSqL的序列sequence的主要内容,如果未能解决你的问题,请参考以下文章

postgresql恢复数据, 自增处理

如何在Postgresql中创建序列数并应用在数据表

如何在Postgresql中创建序列数并应用在数据表

postgresql 清空数据表数据

postgreSQL怎样创建一个序列号/自动递增的字段

PostgreSQL 序列