When you INSERT, you'll get back something like

# CREATE TABLE foo ( a int );
# INSERT INTO foo VALUES (1),(2);

What is the first and second number after the INSERT (the 0 and the 2)?

closed as off-topic by Philᵀᴹ, kevinsky, Max Vernon, Colin 't Hart, Marcello Miorelli May 30 at 19:05

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Too localized - this could be because your code has a typo, basic error, or is not relevant to most of our audience. Consider revising your question so that it appeals to a broader audience. As it stands, the question is unlikely to help other users (regarding typo questions, see this meta question for background)." – Philᵀᴹ, kevinsky, Max Vernon, Colin 't Hart, Marcello Miorelli
If this question can be reworded to fit the rules in the help center, please edit the question.


According to the docs on INSERT

On successful completion, an INSERT command returns a command tag of the form

INSERT oid count

The count is the number of rows inserted or updated. If count is exactly one, and the target table has OIDs, then oid is the OID assigned to the inserted row. The single row must have been inserted rather than updated. Otherwise oid is zero.

This is pretty much a legacy feature. PostgreSQL doesn't, by default, assign OIDs to rows anymore. So this feature is only useful if,

  • If the table was CREATEd with the option WITH OIDS.
  • If only one row was inserted.

As noted by Sahap Asci in the comments, when PostgreSQL 12 drops table creation will no longer even support WITH OIDS. From the docs of WITHOUT OIDS on PostgreSQL 12,

This is backward-compatible syntax for declaring a table WITHOUT OIDS, creating a table WITH OIDS is not supported anymore.

  • After version 12, oid's can no longer be added to user created tables using the WITH OIDS clause. – Sahap Asci May 27 at 17:20
  • @SahapAsci hrm, wonder if v12 will deprecate this verbose output on the INSERT. – Evan Carroll May 27 at 17:21
  • 1
    I hope so. And remove it in version 14 or 15. – Colin 't Hart May 27 at 20:02
  • 1
    @EvanCarroll I just tested insert in v 12 beta and get the same output format INSERT 0 1 – Sahap Asci May 28 at 16:43

Not the answer you're looking for? Browse other questions tagged or ask your own question.