Extracted from the page in the manual :
Exits
On successful completion of a command INSERT it returns a form command tag:
INSERT [oid] [Count]
The [Count] count is the number of rows entered. If the [Count] count is exactly A and the target table has Oids enabled, the OID is assigned to the inserted row. Otherwise OID is zero.
Oids are used internally by Postgresql as primary keys in various system tables. It would be almost the same thing as ROWID oracle.
Exemplifying:
OID will appear only if you INSERT A LINE. Because the return is singular (single Return), so it is shown 0 for inserting many records, but behind it is generated the OID for each record inserted in the table. (unless WITHOUT OIDS is specified in the table creation, or the default_with_oids configuration variable is set to false.)
Running some INSERT’s:
INSERT INTO t VALUES ('x', 'x', 'x');
INSERT INTO t VALUES ('x', 'x', 'y');
INSERT INTO t VALUES ('x', 'y', 'x');
INSERT INTO t VALUES ('x', 'x', 'y');
INSERT INTO t VALUES ('x', 'x', 'y');
INSERT INTO t VALUES ('x', 'y', 'y');
INSERT INTO t VALUES ('y', 'y', 'y');
INSERT INTO t VALUES ('y', 'y', 'y');
SELECT oid, t.* FROM t;
oid | c1 | c2 | c3
-------+----+----+----
17839 | x | x | x
17840 | x | x | y
17841 | x | y | x
17842 | x | x | y
17843 | x | x | y
17844 | x | y | y
17845 | y | y | y
17846 | y | y | y
(8 linhas)
Each record is assigned a OID
different, because internally each record (line) is a different object.
DELETE FROM t WHERE oid NOT IN
(SELECT min(oid) FROM t GROUP BY c1, c2, c3);
DELETE 3
SELECT oid, t.* FROM t;
oid | c1 | c2 | c3
-------+----+----+----
17839 | x | x | x
17840 | x | x | y
17841 | x | y | x
17844 | x | y | y
17845 | y | y | y
I found an explanation here on forum of Postgre that can be useful @Guilherme! In translation it says the following: Newer & #Xa; Postgresql versions by default have tables created without
OIDs
on the lines, then you just get a0
returned instead.– Marconi
@Not Everson, I even researched about it, but I didn’t go into it to say that I know.
– Guilherme Lautert
If you send a duplicate value in this Index, the output is: 1068, 0?
– rray
@rray no, it’s still
INSERT 0 1
;– Guilherme Lautert