Search Postgresql Archives

Re: Find schema-qualified table name given unqualified name

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Aron Widforss <pgsql-general@xxxxxxxxxx> 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





[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux