pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedFind schema-qualified table name given unqualified name
2+ messages / 2 participants
[nested] [flat]
* Find schema-qualified table name given unqualified name
@ 2018-06-19 14:20 Aron Widforss <pgsql-general@antarkt.is>
0 siblings, 1 reply; 2+ messages in thread
From: Aron Widforss @ 2018-06-19 14:20 UTC (permalink / raw)
To: pgsql-general
Hi,
I'm interested in finding a (any) unique identifier for a table given an unqualified name of the table. Is that feasible in SQL or a C function?
Regards,
Aron Widforss
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Find schema-qualified table name given unqualified name
@ 2018-06-19 15:06 Tom Lane <tgl@sss.pgh.pa.us>
parent: Aron Widforss <pgsql-general@antarkt.is>
0 siblings, 0 replies; 2+ messages in thread
From: Tom Lane @ 2018-06-19 15:06 UTC (permalink / raw)
To: Aron Widforss <pgsql-general@antarkt.is>; +Cc: pgsql-general
Aron Widforss <pgsql-general@antarkt.is> writes:
> I'm interested in finding a (any) unique identifier for a table given an unqualified name of the table. Is that feasible in SQL or a C function?
Something like this might help you:
select relnamespace::regnamespace from pg_class
where oid = 'mytablename'::regclass;
This will fail (not just return an empty set) if 'mytablename' isn't
resolvable, so you might need some hackery to cope with that. Also,
if you need it to work pre-9.5, you'll need to write an explicit
join to pg_namespace instead of relying on regnamespace.
regards, tom lane
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2018-06-19 15:06 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-06-19 14:20 Find schema-qualified table name given unqualified name Aron Widforss <pgsql-general@antarkt.is>
2018-06-19 15:06 ` Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox