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 1rPsNI-00ErGO-48 for pgsql-general@arkaria.postgresql.org; Tue, 16 Jan 2024 22:57:40 +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 1rPsNH-008tCI-4X for pgsql-general@arkaria.postgresql.org; Tue, 16 Jan 2024 22:57:39 +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 1rPsNG-008tCA-GU for pgsql-general@lists.postgresql.org; Tue, 16 Jan 2024 22:57:38 +0000 Received: from mail-pg1-x52f.google.com ([2607:f8b0:4864:20::52f]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rPsND-001tAg-QE for pgsql-general@lists.postgresql.org; Tue, 16 Jan 2024 22:57:37 +0000 Received: by mail-pg1-x52f.google.com with SMTP id 41be03b00d2f7-5cf1f4f6c3dso3330150a12.2 for ; Tue, 16 Jan 2024 14:57:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705445855; x=1706050655; darn=lists.postgresql.org; h=in-reply-to:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=uk8rY8ou4mBpNAUB1XunpD6t+E8znSK2TQwuNRc3Bms=; b=NbbSJNjeO3NmaoOGMTXzOc1tiyRPR6kMFuud86ZwuQOQ3KQ3GsC90Zska+n8GDkpKe PUzBYJiNnuLscuGCb1eoH9duVeLkTVs+3X42IFLEyXyKwRCSMVtx3qoMVJwyuJigoD53 6mXF1VgroEkOkq4gd4cANhBi0Ea2ALAcGvrnJKABfVBgRnhAqt/rllTp5yzb249vrHuw 8K27g8+pDs0WAjsDzd06k/qYY0rGy8BYvfoyXKPhYESXbNKpPkZVw395Kg280wmrmcEr 5gubEFvdFqUbBYmSxj6SsVHiaUNdL1ngKvE6OIf0YcDfrNXkB0ufwMr5gRLB6eZ5g2by x+Gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705445855; x=1706050655; h=in-reply-to:from:references:cc: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=uk8rY8ou4mBpNAUB1XunpD6t+E8znSK2TQwuNRc3Bms=; b=FLxk61302lppfYUIs4pRMILfieRnaI/U6UuAGUJhOu74j8IUF6fq6qnv0wyC9oR2Y6 p0Y8UczngO6nVnvqhIIVQqxChcr0pZC5x7HxxKr/oYphAomLgt/d6tB7lykKwsXDVAU9 jLRsjvV+/xzvU8b/Rsxf+kPyC933mxd2cwVOJee+N0093V329bIfYA9BYRvQTvDEVKWP DOkWHUu6Y7N45SSV685EXsAX9xd7GZ81wVefbut3m4POskPDEAWOUyLwU0X2f2EX8J2C JSU3Pnb7pQ5NfPQofAVdPbbDhVqp+FUaKVlFtmSadro5HBzzT/MeYy8xx+NxkV7dzJOz VjdA== X-Gm-Message-State: AOJu0Yzzy9bMadCqbQRMUtqqvGeYbEJq1OMWTYTJWOd3oBAVmUWY0+T1 5ouwrOLgQn1mK54s0KYCQbQ= X-Google-Smtp-Source: AGHT+IGXIp7rHp5JRdaiN2khNcEcbuoW0MzUYS+GZGHvlvLqi7u6DPkHog86P471Ay9sTauvQfbYcQ== X-Received: by 2002:a05:6a20:e104:b0:19a:55ba:43d6 with SMTP id kr4-20020a056a20e10400b0019a55ba43d6mr4507711pzb.11.1705445854891; Tue, 16 Jan 2024 14:57:34 -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 sh2-20020a17090b524200b0028dfdfc9a8esm10884879pjb.37.2024.01.16.14.57.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 16 Jan 2024 14:57:34 -0800 (PST) Content-Type: multipart/alternative; boundary="------------1nygS60Cjyb2l8kqQLJ3t3BN" Message-ID: Date: Tue, 16 Jan 2024 15:57:33 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Mimic ALIAS in Postgresql? Content-Language: en-CA To: Ron Johnson Cc: pgsql-general@lists.postgresql.org References: <484b48cd-3a6e-4585-be9b-febed445e18b@gmail.com> 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. --------------1nygS60Cjyb2l8kqQLJ3t3BN Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 1/16/24 15:39, Ron Johnson wrote: > On Tue, Jan 16, 2024 at 5:31 PM Rob Sargent wrote: > > 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. > > > I'm not a Java web developer... 😁 You need to adjust you glasses if that's what you see me as. --------------1nygS60Cjyb2l8kqQLJ3t3BN Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit
On 1/16/24 15:39, Ron Johnson wrote:
On Tue, Jan 16, 2024 at 5:31 PM Rob Sargent <robjsargent@gmail.com> wrote:
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.

I'm not a Java web developer... 😁

You need to adjust you glasses if that's what you see me as.

--------------1nygS60Cjyb2l8kqQLJ3t3BN--