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

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -