ALTER ROLE role-name-with-hyphen

Started by Tom Copelandover 17 years ago4 messagesgeneral
Jump to latest
#1Tom Copeland
tom@infoether.com

Hi all -

This is probably a new bee question... but, how do I change the
password of a role that has a hyphen in the name?

======================
$ createuser --no-superuser --createdb --no-createrole foo-bar
$ psql
Welcome to psql 8.3.0, the PostgreSQL interactive terminal.

Type: \copyright for distribution terms
\h for help with SQL commands
\? for help with psql commands
\g or terminate with semicolon to execute query
\q to quit

postgres=# ALTER USER foo-bar WITH ENCRYPTED PASSWORD 'foo-bar';
ERROR: syntax error at or near "-"
LINE 1: ALTER USER foo-bar WITH ENCRYPTED PASSWORD 'foo-bar';
^
======================

So I can create the role but I can't figure out how to modify it.
I've tried a variety of quoting and backslashing and such, but no luck
yet.... any ideas?

Thanks,

Tom

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Tom Copeland (#1)
Re: ALTER ROLE role-name-with-hyphen

Tom Copeland <tom@infoether.com> writes:

This is probably a new bee question... but, how do I change the
password of a role that has a hyphen in the name?

You need double quotes, not single quotes. Read about SQL identifier
syntax in the fine manual ...

regards, tom lane

#3Tom Copeland
tom@infoether.com
In reply to: Tom Lane (#2)
Re: ALTER ROLE role-name-with-hyphen

On Aug 8, 2008, at 4:57 PM, Tom Lane wrote:

Tom Copeland <tom@infoether.com> writes:

This is probably a new bee question... but, how do I change the
password of a role that has a hyphen in the name?

You need double quotes, not single quotes. Read about SQL identifier
syntax in the fine manual ...

Argh.... I could have sworn I tried that... awesome, that works great,
thanks much!

Yours,

Tom

#4Lennin Caro
lennin.caro@yahoo.com
In reply to: Tom Copeland (#1)
Re: ALTER ROLE role-name-with-hyphen

use the double quotes (")

ALTER USER "foo-bar" WITH ENCRYPTED PASSWORD 'foo-bar'

--- On Fri, 8/8/08, Tom Copeland <tom@infoether.com> wrote:
Show quoted text

From: Tom Copeland <tom@infoether.com>
Subject: [GENERAL] ALTER ROLE role-name-with-hyphen
To: pgsql-general@postgresql.org
Date: Friday, August 8, 2008, 8:49 PM
Hi all -

This is probably a new bee question... but, how do I change
the
password of a role that has a hyphen in the name?

======================
$ createuser --no-superuser --createdb --no-createrole
foo-bar
$ psql
Welcome to psql 8.3.0, the PostgreSQL interactive terminal.

Type: \copyright for distribution terms
\h for help with SQL commands
\? for help with psql commands
\g or terminate with semicolon to execute query
\q to quit

postgres=# ALTER USER foo-bar WITH ENCRYPTED PASSWORD
'foo-bar';
ERROR: syntax error at or near "-"
LINE 1: ALTER USER foo-bar WITH ENCRYPTED PASSWORD
'foo-bar';
^
======================

So I can create the role but I can't figure out how to
modify it.
I've tried a variety of quoting and backslashing and
such, but no luck
yet.... any ideas?

Thanks,

Tom

--
Sent via pgsql-general mailing list
(pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general