Search code examples
postgresqloracle-databasepostgresql-13

Get session number from namespace USERENV in postgresql


While migrating oracle to postgresql I came up with the query:

Oracle:

select SYS_CONTEXT('USERENV','SID') from dual;

What will be the equivalent in PostgreSQL?


Solution

  • The only thing I can think of is the backend PID

    select pg_backend_pid();