how to insert row with specific oid

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

how to insert row with specific oid

ZongtianHou
Hi, all

Could I insert a row to table with specific row oid. just like insert into tbl values (xx,xx) oid=xx? Is there some syntax to do this?

Best Regards,
Zongtian

Reply | Threaded
Open this post in threaded view
|

Re: how to insert row with specific oid

Laurenz Albe
On Fri, 2020-06-19 at 15:02 +0800, ZongtianHou wrote:
> Could I insert a row to table with specific row oid. just like insert
> into tbl values (xx,xx) oid=xx? Is there some syntax to do this?

No, you cannot determine the OID that will be inserted.

Using tables WITH OIDS is deprecated, and the feature is gone in v12.

If you want to insert specific values, you shouldn't be using a
system-generated OID but a regular column of type "bigint" or so.

Yours,
Laurenz Albe
--
Cybertec | https://www.cybertec-postgresql.com



Reply | Threaded
Open this post in threaded view
|

Re: how to insert row with specific oid

ZongtianHou
Thank you for the detailed answer!

> On Jun 19, 2020, at 3:13 PM, Laurenz Albe <[hidden email]> wrote:
>
> On Fri, 2020-06-19 at 15:02 +0800, ZongtianHou wrote:
>> Could I insert a row to table with specific row oid. just like insert
>> into tbl values (xx,xx) oid=xx? Is there some syntax to do this?
>
> No, you cannot determine the OID that will be inserted.
>
> Using tables WITH OIDS is deprecated, and the feature is gone in v12.
>
> If you want to insert specific values, you shouldn't be using a
> system-generated OID but a regular column of type "bigint" or so.
>
> Yours,
> Laurenz Albe
> --
> Cybertec | https://www.cybertec-postgresql.com
>



Reply | Threaded
Open this post in threaded view
|

Re: how to insert row with specific oid

Tom Lane-2
In reply to this post by ZongtianHou
ZongtianHou <[hidden email]> writes:
> Could I insert a row to table with specific row oid. just like insert into tbl values (xx,xx) oid=xx? Is there some syntax to do this?

Nope, at least not in PG versions that have special oid columns at all.
(Since v12, if you want an OID column, it's just a regular column.)

                        regards, tom lane