pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedtable name
5+ messages / 4 participants
[nested] [flat]
* table name
@ 2020-06-11 18:54 Marc Millas <marc.millas@mokadb.com>
2020-06-11 18:55 ` Re: table name Paul Ramsey <pramsey@cleverelephant.ca>
2020-06-11 18:58 ` Re: table name Paul Förster <paul.foerster@gmail.com>
0 siblings, 2 replies; 5+ messages in thread
From: Marc Millas @ 2020-06-11 18:54 UTC (permalink / raw)
To: pgsql-general
sorry if my question is tooo simple :-)
I got a shapefile from the french gov.
I import it with postgis 3.01 utility.
fine !
the table created by this utility is named regions-20180101
with the dash in the middle.
I see that table name in pg_class, and, also, in the geometry_columns view.
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 ?
thanks,
Marc MILLAS
Senior Architect
+33607850334
www.mokadb.com
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: table name
2020-06-11 18:54 table name Marc Millas <marc.millas@mokadb.com>
@ 2020-06-11 18:55 ` Paul Ramsey <pramsey@cleverelephant.ca>
2020-06-11 18:58 ` Re: table name Marc Millas <marc.millas@mokadb.com>
1 sibling, 1 reply; 5+ messages in thread
From: Paul Ramsey @ 2020-06-11 18:55 UTC (permalink / raw)
To: Marc Millas <marc.millas@mokadb.com>; +Cc: pgsql-general
ALTER TABLE "regions-20180101" rename to regions_20180101;
> On Jun 11, 2020, at 11:54 AM, Marc Millas <marc.millas@mokadb.com> wrote:
>
> sorry if my question is tooo simple :-)
>
> I got a shapefile from the french gov.
> I import it with postgis 3.01 utility.
> fine !
> the table created by this utility is named regions-20180101
> with the dash in the middle.
> I see that table name in pg_class, and, also, in the geometry_columns view.
>
>
> 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 ?
>
> thanks,
>
>
> Marc MILLAS
> Senior Architect
> +33607850334
> www.mokadb.com
>
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: table name
2020-06-11 18:54 table name Marc Millas <marc.millas@mokadb.com>
2020-06-11 18:55 ` Re: table name Paul Ramsey <pramsey@cleverelephant.ca>
@ 2020-06-11 18:58 ` Marc Millas <marc.millas@mokadb.com>
0 siblings, 0 replies; 5+ messages in thread
From: Marc Millas @ 2020-06-11 18:58 UTC (permalink / raw)
To: Paul Ramsey <pramsey@cleverelephant.ca>; +Cc: pgsql-general
damn..
thanks
Marc MILLAS
Senior Architect
+33607850334
www.mokadb.com
On Thu, Jun 11, 2020 at 8:55 PM Paul Ramsey <pramsey@cleverelephant.ca>
wrote:
> ALTER TABLE "regions-20180101" rename to regions_20180101;
>
>
> > On Jun 11, 2020, at 11:54 AM, Marc Millas <marc.millas@mokadb.com>
> wrote:
> >
> > sorry if my question is tooo simple :-)
> >
> > I got a shapefile from the french gov.
> > I import it with postgis 3.01 utility.
> > fine !
> > the table created by this utility is named regions-20180101
> > with the dash in the middle.
> > I see that table name in pg_class, and, also, in the geometry_columns
> view.
> >
> >
> > 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 ?
> >
> > thanks,
> >
> >
> > Marc MILLAS
> > Senior Architect
> > +33607850334
> > www.mokadb.com
> >
>
>
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: table name
2020-06-11 18:54 table name Marc Millas <marc.millas@mokadb.com>
@ 2020-06-11 18:58 ` Paul Förster <paul.foerster@gmail.com>
2020-06-11 19:34 ` Re: table name Alban Hertroys <haramrae@gmail.com>
1 sibling, 1 reply; 5+ messages in thread
From: Paul Förster @ 2020-06-11 18:58 UTC (permalink / raw)
To: Marc Millas <marc.millas@mokadb.com>; +Cc: pgsql-general
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
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: table name
2020-06-11 18:54 table name Marc Millas <marc.millas@mokadb.com>
2020-06-11 18:58 ` Re: table name Paul Förster <paul.foerster@gmail.com>
@ 2020-06-11 19:34 ` Alban Hertroys <haramrae@gmail.com>
0 siblings, 0 replies; 5+ messages in thread
From: Alban Hertroys @ 2020-06-11 19:34 UTC (permalink / raw)
To: Paul Förster <paul.foerster@gmail.com>; +Cc: Marc Millas <marc.millas@mokadb.com>; 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 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.
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2020-06-11 19:34 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-06-11 18:54 table name Marc Millas <marc.millas@mokadb.com>
2020-06-11 18:55 ` Paul Ramsey <pramsey@cleverelephant.ca>
2020-06-11 18:58 ` Marc Millas <marc.millas@mokadb.com>
2020-06-11 18:58 ` Paul Förster <paul.foerster@gmail.com>
2020-06-11 19:34 ` Alban Hertroys <haramrae@gmail.com>
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