Search code examples
postgresqlforeign-data-wrapper

Postgres: How do you create a USER MAPPING for a user whose name includes a period character ('.')


Postgresql 9.6:

Trying to run this SQL:

CREATE USER MAPPING FOR wes.gamble
            SERVER fdw_server
            OPTIONS (user 'username', password 'password')

It fails because of the period. But 'wes.gamble' is a valid Postgres user.

I tried escaping the period with a backslash (wes.gamble).

I tried using single quotes ('wes.gamble').

I cannot get this CREATE USER MAPPING command to run with any name that contains a period.

Any ideas on how I can get such a command to work?


Solution

  • You need to use a quoted identifier. In this particular case "wes.gamble" should do the job (note double quotes).

    Here's some more information about identifiers in PostgreSQL documentation.