Re: table name - Mailing list pgsql-general

From Alban Hertroys
Subject Re: table name
Date
Msg-id B55AFAD6-264F-4473-9661-F9DE091EDBE5@gmail.com
Whole thread Raw
In response to Re: table name  (Paul Förster <paul.foerster@gmail.com>)
List pgsql-general
> On 11 Jun 2020, at 20:58, Paul Förster <paul.foerster@gmail.com> wrote:
>
> Hi Marc,
>
>> On 11. Jun, 2020, at 20:54, Marc Millas <marc.millas@mokadb.com> wrote:
>> sorry if my question is tooo simple :-)
>
> it's not. :-)
>
>> obviously if I ask:
>> select * from regions-20180101;
>> I get a syntax error.
>> if I try select * from $$regions_20180101$$;
>> I get another syntax error.
>> If I try to rename that table, same thing.
>> if I try a cte, same thing.
>>
>> What should I do ?
>
> you can just quote its name:
>
> select * from "regions-20180101";
>
> Cheers,
> Paul

The background here is that ‘’ and $$ are quoting of literals (strings, integers, JSON objects, etc.), while “” is
identifierquoting (tables, indices, types, etc.). 

Identifier quoting not only allows to include special symbols, it also makes the identifier case-sensitive. That’s
probablywhy Paul suggested to rename the table to no longer require identifier quoting - many people consider it a
PITA,but it can be used to get out of trouble like yours - some people insist on it, for example because it makes using
camel-capsin identifiers meaningful. 

Regards,

Alban Hertroys
--
There is always an exception to always.







pgsql-general by date:

Previous
From: George Dimopoulos
Date:
Subject: ora2pg error : DBD::Oracle::db prepare failed: ORA-28110
Next
From: Adrian Klaver
Date:
Subject: Re: ora2pg error : DBD::Oracle::db prepare failed: ORA-28110