Re: How to choose table in SELECT clause without schema qualifier or 'set local'

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: intmail01 <intmail01(at)gmail(dot)com>
Cc: "pgsql-sql(at)lists(dot)postgresql(dot)org" <pgsql-sql(at)lists(dot)postgresql(dot)org>
Subject: Re: How to choose table in SELECT clause without schema qualifier or 'set local'
Date: 2024-03-22 13:28:42
Message-ID: CAKFQuwbpYt=P2RudjAs_ZMUHZEO9PWrVcBhX9bR7GRUvTHPu+Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Friday, March 22, 2024, intmail01 <intmail01(at)gmail(dot)com> 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.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message David G. Johnston 2024-03-22 13:35:22 Re: UPDATE with AND clarification
Previous Message Jamie Thompson 2024-03-22 11:36:54 UPDATE with AND clarification