how to solve the rowid (Pseudocolumn) of oracle in postgres

1.4k Views Asked by At

oracle has something called row id which nothing but a Pseudo column, is there any alternative of that present in postgres and EDB. if yes that what is that and if not how I can solve this issue.

for refernce

SELECT /*+ PARALLEL(2) FULL(t) */ 
rowid, account_id, service_id, charge_date
FROMemployee %s t;
2

There are 2 best solutions below

2
Laurenz Albe On

The correct replacement is the primary key of the table.

PostgreSQL does have an equivalent to Oracle's ROWID, which is ctid, but owing to the different implementation, that value changes with every update and cannot be used to reliably identify a table row across different SQL statements.

0
Nikhil S On

This is a simple workaround for it:

select rank() over (partition by <primary key> order by <primary key>) as rn,* 
from <tablename>;