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 1rPrxi-00EoJq-6A for pgsql-general@arkaria.postgresql.org; Tue, 16 Jan 2024 22:31:14 +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 1rPrxg-008gHi-0B for pgsql-general@arkaria.postgresql.org; Tue, 16 Jan 2024 22:31:12 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rPrxf-008gHZ-LZ for pgsql-general@lists.postgresql.org; Tue, 16 Jan 2024 22:31:11 +0000 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rPrxd-002BpW-3d for pgsql-general@lists.postgresql.org; Tue, 16 Jan 2024 22:31:11 +0000 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1d6efe27c1dso70565ad.0 for ; Tue, 16 Jan 2024 14:31:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705444266; x=1706049066; darn=lists.postgresql.org; h=in-reply-to:from:references:to:content-language:subject:user-agent :mime-version:date:message-id:from:to:cc:subject:date:message-id :reply-to; bh=hKTRHAZpYmotgHZ7uA62jIzjU+MspOf/CHFvuLmuFhE=; b=f4lo0GG/l+Dr40pdBLSc9URBQrDrZNlJ+TeN0IveO0MeZcc2CNeIBXyFcM/1K0HkGn VHZIEfhCfUrG3fPEX9mKLb/jLHP4rVc9LBZWGZp65ndOOwriuSmJWoUjvITIYtSYmoou v1J8bedhVqr/Edr87+Khaz5/y0kaLT96H3saG63r2fKGdKI2xQfDI3Ow9JcP34IVOXGi QkSxSN5aQ5lJVvKd5urkKh16fcqIL3axdjVykrPSIkykwYaH2jXxeWF4vogIrbJi7kZ0 8BpLQuX6c0oH6oHkhi7ZsaSvjoYTLnBoATFE6gTQQVs0uEbsMnOnqwrkySqLK1CSzPuT Cn2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705444266; x=1706049066; h=in-reply-to:from:references:to:content-language:subject:user-agent :mime-version:date:message-id:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=hKTRHAZpYmotgHZ7uA62jIzjU+MspOf/CHFvuLmuFhE=; b=LI+BtogzcW3k8Zad6lZOneFkpb4wCSQYyveV2zfAvEx3GOkIhG947ZBeV+z62DRoSE emYozPbpmKVkXFRVNfWjLqRyjfDQHi5xLFFdPBFBhNJUgv90r82DEeAkfZYAqikp3sxG uCzJV5Vx3uZIorRyDS0FmAiASvxhzKoI/NEyjutf3lj+jUcrkPpV/SBlxBHQWyUhVz/g Xh7fClluEZKSg8vxOB1AZPFrkusVymyEe6+BjvdoBTgP7CGpUjwe+GBhksjwf09wwoYa dlZjuPlF2oHvjCEqdA58Kaw9xhad+t4jdSO5rEGJdcxNI/xhft+PeaV7K6Djf8q2Lr/J nr3w== X-Gm-Message-State: AOJu0YzmtSjTM3aBwzqL412QOjrD/GVpcMWXFhamE9DL6qnHCdf5zpql TqeF2DiR+hhZRtuT0QRbi3DfU2Cv++4= X-Google-Smtp-Source: AGHT+IHzyWECeqPqoPXZL3N24ymg1NYioYL4sjjkCo7gPJB2iGa8q3uz+0FoY+sQjPOMz24eizgmWw== X-Received: by 2002:a17:902:cec4:b0:1d5:8d07:6e1 with SMTP id d4-20020a170902cec400b001d58d0706e1mr5762863plg.130.1705444265765; Tue, 16 Jan 2024 14:31:05 -0800 (PST) Received: from [192.168.1.3] (c-76-140-27-218.hsd1.ut.comcast.net. [76.140.27.218]) by smtp.gmail.com with ESMTPSA id y11-20020a1709027c8b00b001d3bf27000csm9778065pll.293.2024.01.16.14.31.05 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 16 Jan 2024 14:31:05 -0800 (PST) Content-Type: multipart/alternative; boundary="------------4fOwRfYmv6c7bdzkOUFEIKHP" Message-ID: <484b48cd-3a6e-4585-be9b-febed445e18b@gmail.com> Date: Tue, 16 Jan 2024 15:31:04 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Mimic ALIAS in Postgresql? Content-Language: en-CA To: pgsql-general@lists.postgresql.org References: From: Rob Sargent In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------4fOwRfYmv6c7bdzkOUFEIKHP Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 1/16/24 10:20, Ron Johnson wrote: > Some RDBMSs have CREATE ALIAS, which allows you to refer to a table by > a different name (while also referring to it by the original name). > > We have an application running on DB2/UDB which (for reasons wholly > unknown to me, and probably also to the current developer) extensively > uses this with two schemas: MTUSER and MTQRY.  For example, sometimes > refer to MTUSER.sometable and other times refer to it as MYQRY.sometable. > > My goal is to present a way to migrate from UDB to PG with as few > application changes as possible.  Thus, the need to mimic aliases. > > Maybe updatable views? > CREATE VIEW mtqry.sometable AS SELECT * FROM mtuser.sometable; > Isn't it time to get rid of that debt?  A sed -i 's/MTUSER/MTQRY/g' (or vice versa) ends what looks to me to be a split brain problem.  All the sql is in git right? :) Or perhaps you have to beef the sed up to use word boundaries just in case. --------------4fOwRfYmv6c7bdzkOUFEIKHP Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit
On 1/16/24 10:20, Ron Johnson wrote:
Some RDBMSs have CREATE ALIAS, which allows you to refer to a table by a different name (while also referring to it by the original name).

We have an application running on DB2/UDB which (for reasons wholly unknown to me, and probably also to the current developer) extensively uses this with two schemas: MTUSER and MTQRY.  For example, sometimes refer to MTUSER.sometable and other times refer to it as MYQRY.sometable.

My goal is to present a way to migrate from UDB to PG with as few application changes as possible.  Thus, the need to mimic aliases.

Maybe updatable views?
CREATE VIEW mtqry.sometable AS SELECT * FROM mtuser.sometable;

Isn't it time to get rid of that debt?  A sed -i 's/MTUSER/MTQRY/g' (or vice versa) ends what looks to me to be a split brain problem.  All the sql is in git right? :) 

Or perhaps you have to beef the sed up to use word boundaries just in case.



--------------4fOwRfYmv6c7bdzkOUFEIKHP--