2014-12-03 81 views
1

我将数据插入到PostgreSQL数据库中。我做这样的事情:PostgreSQL插入后输出的结果究竟意味着什么?

$ psql test -c "insert into items (name) values ('test name') returning id " -At 
4 
INSERT 0 1 

INSERT 0 1中的第一个数字是指什么?我假设第二个数字是受影响或创建的行数。

回答

2

这是“命令标签”。那就是这里answering on the pgsql general list清单报价没有给信用,当他引述directly from the manual的家伙:

对于INSERT命令时,标签是INSERT oid rows,中行是 数插入行。 oid是插入行的对象ID,如果 rows为1且目标表具有OID;否则oid为0.

大胆强调我的。

1

成功完成后,一个INSERT命令返回的形式

INSERT oid count

的命令标签计数是被插入的行数。如果count恰好是1,并且目标表具有OID,则oid是分配给插入行的OID。否则,oid为零。欲了解更多信息,请登录this link

相关问题