I am inserting data into a PostgreSQL database. I do something like this:
$ psql test -c "insert into items (name) values ('test name') returning id " -At
4
INSERT 0 1
What does the first number in INSERT 0 1
refer to? I assume the second number is the number of rows affected or created.
It's the "command tag". And the guy that was quoted here answering on the pgsql general list list didn't give credit when he quoted directly from the manual:
For an
INSERT
command, the tag isINSERT
oid rows
, whererows
is the number of rows inserted.oid
used to be the object ID of the inserted row ifrows
was 1 and the target table had OIDs, but OIDs system columns are not supported anymore; thereforeoid
is always 0.
(Updated quote for Postgres 14.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With