This doesn't work
CREATE ROLE "role-one" LOGIN;
CREATE ROLE "other_role" LOGIN WITH "role-one";
I get this error
ERROR: unrecognized role option "role-one"
LINE 1: CREATE ROLE "other_role" WITH "role-one";
What am I doing wrong? I can't find examples online that make it clear to me what the syntax is. From what I have seen this should work.
How do I create a new role with LOGIN and add it to another role named role-one?
Because you use a wrong syntax. Let me cite the manual:
(I skipped uninteresting parts).
So, correct syntax would be either:
other_role
to be a member ofrole-one
:role-one
to become a member ofother_role
(the reverse):Notice keywords
ROLE
andIN ROLE
which you skipped, apparently.There is also a way to create role and grant a membership in two distinct commands, which is perfectly explained with detailed example, again, in another manual page:
In this case,
other_role
will be a member ofrole-one
. To do the reverse thing, swap them in the last GRANT.Also, unrelated advices: