37

I'm having difficulty modifying a postgres user that contains a dash in its name - I've run into this problem several times, but can never find the answer (no matter how much googling I do!).

osm=# grant all on osm_polygon_view to www-data;

ERROR: syntax error at or near "-"

LINE 1: grant all on osm_polygon_view to www-data;

                                       ^

I have tried just about every permutation of escape characters and quotes, and still can't get this to work. I have also encountered this when trying to change www-data password.

Community
  • 1
  • 1
gavz
  • 1,151
  • 1
  • 8
  • 8

1 Answers1

68

Double quotes is what you should use - not single quotes.

grant all on osm_polygon_view to "www-data";

gavz
  • 1,151
  • 1
  • 8
  • 8
  • 5
    Use double quotes to make 'delimited identifiers' - for things like table names or column names, and for user names. – Jonathan Leffler Feb 19 '10 at 03:41
  • Just want to add that double quotes was necessary for the object name "aaa-bbb-ccc" but I needed *single* quotes for the value 'xxx-yyy-zzz'. A little confusing, but thats how it worked for me :) – vikingsteve Jan 08 '19 at 07:15