Re: Mimic ALIAS in Postgresql?

Поиск
Список
Период
Сортировка
От Ron Johnson
Тема Re: Mimic ALIAS in Postgresql?
Дата
Msg-id CANzqJaC0_evZnPi5tX8fYuTQ0cBbm05A55LgLcdZ8Ahjv6xadQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Mimic ALIAS in Postgresql?  (Adrian Klaver <adrian.klaver@aklaver.com>)
Ответы Re: Mimic ALIAS in Postgresql?
Список pgsql-general
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?

В списке pgsql-general по дате отправления:

Предыдущее
От: Adrian Klaver
Дата:
Сообщение: Re: Moving to Postgresql database
Следующее
От: Ron Johnson
Дата:
Сообщение: Re: Moving to Postgresql database