Php:ingres相当于mysql_insert_id()

时间:2011-08-11 07:26:26

标签: php ingres

我要与Ingres数据库进行一些PHP交互。我需要获取我在数据库中插入的最后一个条目的ID。

我该怎么办?我不是一个ingres专家,但我想也有自动增加的ID /序列/...?

非常感谢

1 个答案:

答案 0 :(得分:2)

last_identity()函数将为您提供表格的最后生成序列号,例如:

SELECT last_identity() FROM t1

根据我的理解,需要使用CREATE TABLE使用以下语法创建序列号:

colname integer generated always as identity

e.g:

CREATE TABLE t1 ( 
    idx integer generated always as identity,
    sometext varchar(100) not null
)

有关使用标识列的其他注意事项,请参阅http://community.ingres.com/wiki/Using_Ingres_Identity_Columns

相关问题