Unable to delete user with special character

0

Hi there,
I have some users in my database with special characters which can't be deleted, any idea how could I do it?

dwh_sch=# select * from pg_user where usename like 'jenn%' ;
usename | usesysid | usecreatedb | usesuper | usecatupd | passwd | valuntil | useconfig
--------------------------------------------------------------------------------+-----------
jenni.tulamito | 125 | f | f | f | ******** | |
(1 row)

dwh_sch=# drop user jenni.tulamito ;
ERROR: syntax error at or near "."
LINE 1: drop user jenni.tulamito ;

Thanks

feita há 4 anos372 visualizações
1 Resposta
0
Resposta aceita

Wrap the username in double quotes.

CREATE USER "test.user" PASSWORD 'Testing123';
-- CREATE USER

select * from pg_user where usename like 'test%';
--   usename  | usesysid | usecreatedb | usesuper | usecatupd |  passwd  | valuntil | useconfig
-- -----------+----------+-------------+----------+-----------+----------+----------+-----------
--  test.user |      121 | f           | f        | f         | ******** |          |
DROP USER "test.user";
-- DROP USER
 
select * from pg_user where usename like 'test%';
--  usename | usesysid | usecreatedb | usesuper | usecatupd | passwd | valuntil | useconfig
-- ---------+----------+-------------+----------+-----------+--------+----------+----------- 
respondido há 4 anos

Você não está conectado. Fazer login para postar uma resposta.

Uma boa resposta responde claramente à pergunta, dá feedback construtivo e incentiva o crescimento profissional de quem perguntou.

Diretrizes para responder a perguntas