Code Monkey home page Code Monkey logo

drop_role_helper's Introduction

This extension makes it easy to DROP ROLE in PostgreSQL.

It provides a function that helps you to revoke all privileges of a role in a database.

Example

You want to get rid of user dummy in the database.

If you want to keep the objects owned by the role, change their ownership to a different role:

REASSIGN OWNED BY dummy TO otheruser;

Then drop everything still owned by the role. This is required even if you ran REASSIGN OWNED, as some objects (for example user mappings) are not affected.

DROP OWNED BY dummy;

Then use the extension to get rid of all the permissions. When using psql, you can use the convenient \gexec to execute the function results as an SQL script:

CREATE EXTENSION drop_role_helper SCHEMA public;
SELECT * FROM public.drop_role_helper('dummy') \gexec

Repeat the above statements in all databases in the PostgreSQL cluster. Then you can drop the role:

DROP ROLE dummy;

Installation

To install the software, make sure that the correct pg_config is on the PATH, change into the directory with the software and run

sudo make install

Then install the extension in the databases where you need it:

CREATE EXTENSION drop_role_helper;

If you don't have permission to install software on the database server, you can simply run the SQL script that creates the function. In that case you don't need to call CREATE EXTENSION.

Usage

The extension creates a single table function drop_role_helper that takes a role name as argument and returns a table of SQL statements.

You need no special permissions to run the function, but to execute the SQL statements returned by the function, you need to be a superuser or the owner of all the affected objects. If the role to be dropped has default privileges, you must also be a member of the role for which the default privileges are defined.

Support

Please report problems by creating a Github issue.
Commercial support is available from Cybertec.

drop_role_helper's People

Contributors

laurenz avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.