1

I want to permissions to a user named foo-bar in PostgreSQL (the key is that the username has a minus '-' in it). However, when I use GRANT ALL PRIVILEGES ON DATABASE baz TO foo-bar, postgres complains about the minus character being invalid syntax. I figured that made sense, I just needed to use a string literal or escape the minus. However, trying the double dollar sign literal syntax here and prepending an E as suggested here didn't work (presumably because the username isn't considered a string here).

So that begs the question, how does one refer to a user in postgres if the user has a minus in their name?

Community
  • 1
  • 1
codeCogs
  • 127
  • 7

1 Answers1

4
GRANT ALL PRIVILEGES ON DATABASE baz TO "foo-bar"

should work

Uku Loskit
  • 40,868
  • 9
  • 92
  • 93
  • Well, now I feel silly. I tried single quotes and it complained about that, but apparently forgot double quotes. – codeCogs Mar 08 '17 at 17:48