Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rnewx-00EOVW-Ae for pgsql-sql@arkaria.postgresql.org; Fri, 22 Mar 2024 13:28:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rnewv-003Y6u-PX for pgsql-sql@arkaria.postgresql.org; Fri, 22 Mar 2024 13:28:46 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rnewv-003Y6m-HK for pgsql-sql@lists.postgresql.org; Fri, 22 Mar 2024 13:28:46 +0000 Received: from mail-oo1-xc2b.google.com ([2607:f8b0:4864:20::c2b]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rnews-005qyT-DE for pgsql-sql@lists.postgresql.org; Fri, 22 Mar 2024 13:28:44 +0000 Received: by mail-oo1-xc2b.google.com with SMTP id 006d021491bc7-5a51c063f99so261392eaf.0 for ; Fri, 22 Mar 2024 06:28:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711114123; x=1711718923; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:references:in-reply-to :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=sO78RA6FbHgUDqu4qrwrk0/of2+zDlAazJdxjBJNcqg=; b=SOr59cLUd5okqQ2kgltXUjJIFB2DSyOUhP1jxfeBUf+jtbBm/cvVp3VC0k9lu2f31l IurkBo7BE2w3CJbo5arhO33wIbwHVBGwOd/qTGF4k9EUNMZknF14idHkw11RjObhyG7C S2JIk6R44OL7SiOlb90dVsKvkBGihUzYL6AYKW3wBSmJzUL5aiHO4BF4SURP5mQcLi/o kUxamiRHM+SpOu62aNT1Q3oSa9prQyesmbcSdr+o+2n9Kp5GZi2GbzGmQGLs0saPPTLC 0WdClr6PInfGbNb9VSKp43XqPiEXOIjKFtvXyv7DlPLgHGXpkzdnlCOfPVo1Dj8JVimV V1IA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711114123; x=1711718923; h=cc:to:subject:message-id:date:from:references:in-reply-to :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=sO78RA6FbHgUDqu4qrwrk0/of2+zDlAazJdxjBJNcqg=; b=FNJxtwrcuONdwoYSt4D1uz3/DfNSUhQqlrb+syJ7FJQZqYnhZJTYQZaFs6AyN9cr+J Qor4itKfR5e4zsORwYuhU1lMwPE8uudm38MA2EwWBai8Xama601wVDmML73BbePH6s+7 jQZ6YrThB7XujHBEy80MPA1Jq/SQqTp47wIj1TYGdruvlrK5CVNaSeFdOX0D5nCddxJZ FSGD1Zh2digEmlv6jNWYXVWhT7z30wdCuk7Sh9qT+UasM2BMpsM49Gu20WSTnpoSTpsC 4yFVD5UdyNbrvz0H/C73DZk6U0DOd+mkBjhOjSB8QhC6iRD1Wh2TcgCVjd9iPXX+VYsr 8IxA== X-Gm-Message-State: AOJu0YxwaYMGh6solFNYJQlAWLAGcKg3MMX7UvLfIzoyZ32Q5xjCTucE MNBQD1qmRWw7EZiFFHnXAa367yPHvHMPlV5OGKJrzpLl68NKSzQ1hzUSWxgL75fkwQDPIP42oi+ kpwNfxCAKaxp0vRREFkltEVXtSIQDUXzO X-Google-Smtp-Source: AGHT+IFTvIjJwxgE9/rFN1VyW/e1Q1CMEvXPMEKDz3ZSgxW16sIU8IsBWUkHpIKkSSbPMCxsgDT76ePir2AWgLC7bJ4= X-Received: by 2002:a05:6820:1e11:b0:5a4:95e6:f15c with SMTP id dh17-20020a0568201e1100b005a495e6f15cmr2450668oob.5.1711114122616; Fri, 22 Mar 2024 06:28:42 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:ac9:7393:0:b0:51b:abdd:416f with HTTP; Fri, 22 Mar 2024 06:28:42 -0700 (PDT) In-Reply-To: References: From: "David G. Johnston" Date: Fri, 22 Mar 2024 06:28:42 -0700 Message-ID: Subject: Re: How to choose table in SELECT clause without schema qualifier or 'set local' To: intmail01 Cc: "pgsql-sql@lists.postgresql.org" Content-Type: multipart/alternative; boundary="00000000000072e57506143fcd5f" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000072e57506143fcd5f Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Friday, March 22, 2024, intmail01 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 tim= e > 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 =E2=80=9Calter role =E2=80=A6 set=E2=80=9D. But it is s= earch_path you need to be using. David J. --00000000000072e57506143fcd5f Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Friday, March 22, 2024, intmail01 <intmail01@gmail.com> wrote:
<= div dir=3D"ltr">
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 cha= nge 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 a= ny schema.


D= o multi-tenant via partitioning and a tenant_id column instead of by schema= .

Otherwise, maybe attach a custom search_path val= ue to the logon user each company uses?=C2=A0 See =E2=80=9Calter role =E2= =80=A6 set=E2=80=9D.=C2=A0 But it is search_path you need to be using.

David J.

--00000000000072e57506143fcd5f--