Re: Add schema to the query

From: Igor Korot <ikorot01(at)gmail(dot)com>
To: Rob Sargent <robjsargent(at)gmail(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Add schema to the query
Date: 2018-05-07 11:38:26
Message-ID: CA+FnnTza8sohzx4fHvkf19BfuiSzwLmQc7-XkHcqyXAtXXdaZA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Rob,

On Sun, May 6, 2018 at 11:54 PM, Rob Sargent <robjsargent(at)gmail(dot)com> wrote:
>
>
>> On May 6, 2018, at 8:19 PM, Igor Korot <ikorot01(at)gmail(dot)com> wrote:
>>
>> Hi, ALL,
>>
>> Is there an easy way to add the schema to the following query:
>>
>> SELECT u.usename FROM pg_class c, pg_user u WHERE u.usesysid =
>> c.relowner AND relname = ?
>>
>> Thank you.
>>
> Are you looking for the owner of a particular schema.tablename?

Yes, I am.

That;s what I ended up with:

SELECT u.usename FROM pg_class c, pg_user u, pg_namespace n WHERE
n.oid = c.relnamespace AND u.usesysid = c.relowner AND n.nspname = ?
AND relname = ?

Thank you.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2018-05-07 13:12:53 Re: psycopg2.DataError: invalid input syntax for integer: ""
Previous Message SRINIVASARAO OGURI 2018-05-07 10:31:07 Re: postgres on physical replica crashes