Re: How to choose table in SELECT clause without schema qualifier or 'set local' - Mailing list pgsql-sql

From David G. Johnston
Subject Re: How to choose table in SELECT clause without schema qualifier or 'set local'
Date
Msg-id CAKFQuwbpYt=P2RudjAs_ZMUHZEO9PWrVcBhX9bR7GRUvTHPu+Q@mail.gmail.com
Whole thread Raw
In response to How to choose table in SELECT clause without schema qualifier or 'set local'  (intmail01 <intmail01@gmail.com>)
List pgsql-sql
On Friday, March 22, 2024, intmail01 <intmail01@gmail.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.

pgsql-sql by date:

Previous
From: Jamie Thompson
Date:
Subject: UPDATE with AND clarification
Next
From: "David G. Johnston"
Date:
Subject: Re: UPDATE with AND clarification