码迷,mamicode.com
首页 > 数据库 > 详细

postgreSqL的序列sequence

时间:2016-12-25 20:56:51      阅读:159      评论:0      收藏:0      [点我收藏+]

标签:over   insert   href   automatic   ati   seq   different   not   pos   

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

标签:over   insert   href   automatic   ati   seq   different   not   pos   

原文地址:http://www.cnblogs.com/oxspirt/p/6220293.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!