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 1rPp39-00EPz2-J3 for pgsql-general@arkaria.postgresql.org; Tue, 16 Jan 2024 19:24: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 1rPp38-006q4V-Kt for pgsql-general@arkaria.postgresql.org; Tue, 16 Jan 2024 19:24:38 +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 1rPp38-006q4M-6N for pgsql-general@lists.postgresql.org; Tue, 16 Jan 2024 19:24:38 +0000 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rPp35-001rYL-E3 for pgsql-general@postgresql.org; Tue, 16 Jan 2024 19:24:36 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id D66835C014D; Tue, 16 Jan 2024 14:24:34 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Tue, 16 Jan 2024 14:24:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1705433074; x=1705519474; bh=7/ZHEkL4c1 41LFYcj/8cd8Yy0UWnP+d20N+I+rOk0BM=; b=FQK7GfKoi4croBPEqt1e80CnCB H/Dneg1q6OcffnIN4ldM6y2/vQBjpkhJk+TIRmNmxpHivhrUgty9EJT4BZN8U5Wn M2aOCpFEOZMydWqqoPJdWe7giHYsGfrfy816h1tNvjQLlywt5LHeS62L1NB8U/GD RSsthRW03nrKzFxuc4GwxE5Baiffc/xjdq1ErQHuN6z/jyu77tqX+Er78uZL9lSN m+EUQsk/ED2zs0FEdLeBVY1pex0rucOrvsgOUzxNpVez/zxVeUdRAAPZ1n43rFvR iJooDHqRK2zuRNABFv4xoZZ2Tx1XrL7WNsvkGdyqtf6bSQR3bf5NjHTXvfCA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1705433074; x=1705519474; bh=7/ZHEkL4c141LFYcj/8cd8Yy0UWn P+d20N+I+rOk0BM=; b=BplJx2UUEYnuvM2WgvBTkMzWqpbtxvkQTe2KkQPHGU6f 9v+RKz9TnM8skRBkZ57i7oX2LA2ZUQC1AzArNC3xQwtkWkLAlqHZWsOLuRHC0Ylx eRfKcZjpaolbVKFdNuNhCWIcLLKP0tqj3XSe1+Q1zrG6mlBk87bytr1Y4MJEAqaG c6YxxvC64xMOxpn732pPTXTjqnL/lzJSum9rFZCFavMN5v3jpq3hgZvSZZitI4gQ Tf6Dot7dknWU+/eglSqDBvVAODksB+u8rZkEy2LO1V/whTK6PRPSULMi7gq5HpRz zvvLc+iLH4kbM1F/Aby7ys5mFlqFDbU2mLdCRH1/zA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvdejfedguddvgecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurheptgfkffggfgfuvfevfhfhjgesrg dtreertddvjeenucfhrhhomheptegurhhirghnucfmlhgrvhgvrhcuoegrughrihgrnhdr khhlrghvvghrsegrkhhlrghvvghrrdgtohhmqeenucggtffrrghtthgvrhhnpedukeejgf dtfeekvefhueekvefhheefveefkeelvddvffeukeekueeiieffudejteenucffohhmrghi nhepphhoshhtghhrvghsqhhlrdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenucfrrg hrrghmpehmrghilhhfrhhomheprggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdr tghomh X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 16 Jan 2024 14:24:34 -0500 (EST) Content-Type: multipart/alternative; boundary="------------F5TBFklojHWCaiRfbdnBlAJw" Message-ID: Date: Tue, 16 Jan 2024 11:24:32 -0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Mimic ALIAS in Postgresql? Content-Language: en-US To: Ron Johnson Cc: pgsql-general References: From: Adrian Klaver 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. --------------F5TBFklojHWCaiRfbdnBlAJw Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 1/16/24 10:11 AM, Ron Johnson wrote: > On Tue, Jan 16, 2024 at 12:40 PM Adrian Klaver > wrote: > > On 1/16/24 09: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). > > > > > > > Maybe updatable views? > > CREATE VIEW mtqry.sometable AS SELECT * FROM mtuser.sometable; > > > > Assuming sometable is the same name in both schemas then the above > will > not work as: > > https://www.postgresql.org/docs/current/sql-createview.html > > "The name of the view must be distinct from the name of any other > relation (table, sequence, index, view, materialized view, or foreign > table) in the same schema." > > You would get a conflict with the existing table MTQRY.sometable. > > > > CREATE VIEW mtqry.sometable AS SELECT * FROM mtuser.sometable; > But mtqry is not the same schema as mtuser.. > > dba=# create schema mtuser; > CREATE SCHEMA > dba=# create schema mtqry; > CREATE SCHEMA > dba=# > dba=# create table mtuser.sometable(f1 int); > CREATE TABLE > dba=# > dba=# create view mtqry.sometable as select * from mtuser.sometable; > CREATE VIEW > > But what are the down-sides that I haven't thought of? What happened to the MYQRY schema in your OP? In the above you still have a relation with the same name in different schema. How does that change the issue? --------------F5TBFklojHWCaiRfbdnBlAJw Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit


On 1/16/24 10:11 AM, Ron Johnson wrote:
On Tue, Jan 16, 2024 at 12:40 PM Adrian Klaver <adrian.klaver@aklaver.com> wrote:
On 1/16/24 09: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).
>

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

Assuming sometable is the same name in both schemas then the above will
not work as:

https://www.postgresql.org/docs/current/sql-createview.html

"The name of the view must be distinct from the name of any other
relation (table, sequence, index, view, materialized view, or foreign
table) in the same schema."

You would get a conflict with the existing table MTQRY.sometable.

> CREATE VIEW mtqry.sometable AS SELECT * FROM mtuser.sometable;
 
But mtqry is not the same schema as mtuser..

dba=# create schema mtuser;
CREATE SCHEMA
dba=# create schema mtqry;
CREATE SCHEMA
dba=#
dba=# create table mtuser.sometable(f1 int);
CREATE TABLE
dba=#
dba=# create view mtqry.sometable as select * from mtuser.sometable;
CREATE VIEW


But what are the down-sides that I haven't thought of?


What happened to the MYQRY schema in your OP?

In the above you still have a relation with the same name in different schema.

How does that change the issue?



--------------F5TBFklojHWCaiRfbdnBlAJw--