public inbox for [email protected]  
help / color / mirror / Atom feed
How to choose table in SELECT clause without schema qualifier or 'set local'
2+ messages / 2 participants
[nested] [flat]

* How to choose table in SELECT clause without schema qualifier or 'set local'
@ 2024-03-22 07:11  intmail01 <[email protected]>
  0 siblings, 1 reply; 2+ messages in thread

From: intmail01 @ 2024-03-22 07:11 UTC (permalink / raw)
  To: [email protected]

Hi,

My db have many schemas (company name) and there are SELECT code related to
tables that I distribute for each company users.

The structure inside are the same for all schemas.

It is a nightmare to change code each time to modify the schema qualifier
or SET LOCAL search_path when I add a new company.
Is there command, configurations or any trick to not modify code each time
I add company then code can works for any schema.

Thanks.


^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: How to choose table in SELECT clause without schema qualifier or 'set local'
@ 2024-03-22 13:28  David G. Johnston <[email protected]>
  parent: intmail01 <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: David G. Johnston @ 2024-03-22 13:28 UTC (permalink / raw)
  To: intmail01 <[email protected]>; +Cc: [email protected] <[email protected]>

On Friday, March 22, 2024, intmail01 <[email protected]> wrote:

> Hi,
>
> My db have many schemas (company name) and there are SELECT code related
> to tables that I distribute for each company users.
>
> The structure inside are the same for all schemas.
>
> It is a nightmare to change code each time to modify the schema qualifier
> or SET LOCAL search_path when I add a new company.
> Is there command, configurations or any trick to not modify code each time
> I add company then code can works for any schema.
>
>
Do multi-tenant via partitioning and a tenant_id column instead of by
schema.

Otherwise, maybe attach a custom search_path value to the logon user each
company uses?  See “alter role … set”.  But it is search_path you need to
be using.

David J.


^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2024-03-22 13:28 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-03-22 07:11 How to choose table in SELECT clause without schema qualifier or 'set local' intmail01 <[email protected]>
2024-03-22 13:28 ` David G. Johnston <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox