pg.ddx.io pgsql-general@postgresql.org mailing list archivehelp / color / mirror / Atom feed
From: Alban Hertroys <haramrae@gmail.com>
To: Paul Förster <paul.foerster@gmail.com>
Cc: Marc Millas <marc.millas@mokadb.com>
Cc: pgsql-general <pgsql-general@postgresql.org>
Subject: Re: table name
Date: Thu, 11 Jun 2020 21:34:26 +0200
Message-ID: <B55AFAD6-264F-4473-9661-F9DE091EDBE5@gmail.com> (raw)
In-Reply-To: <75D93B48-9BBC-41C9-A1F8-CB1142F0A031@gmail.com>
References: <CADX_1aaMDjae0L_MHbfUhnqYnUZCFVFaEZdUSGNr1o0JK4hN3A@mail.gmail.com>
<75D93B48-9BBC-41C9-A1F8-CB1142F0A031@gmail.com>
> 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 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.
view thread (5+ messages)
Message-ID: <B55AFAD6-264F-4473-9661-F9DE091EDBE5@gmail.com> Permalink: ../B55AFAD6-264F-4473-9661-F9DE091EDBE5@gmail.com/ Also on: postgresql.org/message-id/B55AFAD6-264F-4473-9661-F9DE091EDBE5@gmail.com ·
reply
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Reply to all the recipients from your mail client; the link fills in the headers below: reply via email Some clients, webmail especially, drop In-Reply-To and References from a link, and the reply then starts a new thread: use the mbox below. To: pgsql-general@postgresql.org Cc: haramrae@gmail.com, paul.foerster@gmail.com, marc.millas@mokadb.com Subject: Re: table name In-Reply-To: <B55AFAD6-264F-4473-9661-F9DE091EDBE5@gmail.com> References: <CADX_1aaMDjae0L_MHbfUhnqYnUZCFVFaEZdUSGNr1o0JK4hN3A@mail.gmail.com> <75D93B48-9BBC-41C9-A1F8-CB1142F0A031@gmail.com> <B55AFAD6-264F-4473-9661-F9DE091EDBE5@gmail.com> * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox