postgresql delete role with similar names -


i have created roles similar names abc_ number varies abc_ stays same. can see roles following query

select * pg_roles rolname 'abc_%'; 

but don't know how drop role similar name. have got following query takes full name.

drop role name; 

i trying dropping psql , not writing functions. there query to drop roles can have 'abc_%'?

without using dynamic sql of sort, no, can't that. simple example using dynamic sql drop roles:

select 'drop role ' || rolname || ';' pg_roles rolname 'abc_%'; 

if unwilling paste results psql session, can pipe 1 session another.

psql -d yourdb -u youruser -qtac "select 'drop role ' || rolname || ';' pg_roles rolname 'abc_%'" | psql -d yourdb -u youruser 

Comments

Popular posts from this blog

How to logout from a login page in asp.net -

Stack level too deep error after upgrade to rails 3.2 and ruby 1.9.3 -