From: | Alban Hertroys <haramrae(at)gmail(dot)com> |
---|---|
To: | Paul Förster <paul(dot)foerster(at)gmail(dot)com> |
Cc: | Marc Millas <marc(dot)millas(at)mokadb(dot)com>, pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: table name |
Date: | 2020-06-11 19:34:26 |
Message-ID: | B55AFAD6-264F-4473-9661-F9DE091EDBE5@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
> On 11 Jun 2020, at 20:58, Paul Förster <paul(dot)foerster(at)gmail(dot)com> wrote:
>
> Hi Marc,
>
>> On 11. Jun, 2020, at 20:54, Marc Millas <marc(dot)millas(at)mokadb(dot)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 identifier quoting (tables, indices, types, etc.).
Identifier quoting not only allows to include special symbols, it also makes the identifier case-sensitive. That’s probably why 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-caps in identifiers meaningful.
Regards,
Alban Hertroys
--
There is always an exception to always.
From | Date | Subject | |
---|---|---|---|
Next Message | Adrian Klaver | 2020-06-11 20:03:00 | Re: ora2pg error : DBD::Oracle::db prepare failed: ORA-28110 |
Previous Message | George Dimopoulos | 2020-06-11 19:32:14 | ora2pg error : DBD::Oracle::db prepare failed: ORA-28110 |