Bulk delete users by role? SQL?

This can be done efficiently with a SQL query, but it won’t be so easy to set it up. It would have to delete the users, its meta data, to reassign their associated posts, etcetera.

As it is an operation that will run only once and will not have any long-lasting performance impact, I think it can be achieved using some WordPress core functions in a very easy way:

<?php

    /*
        Plugin Name: Delete users by role
        Description: Delete all the users with a hardcoded specific role
        Version: 0.1
        Author: Your name
        Author URI: http://www.yoursite.com/
    */

    function wpse220426_delete_users_by_role() {

        $args = array(
            'role'         => 'user_defined_role' // Modify to match your needs
        );

        $users_to_delete = get_users( $args );

        foreach( $users_to_delete as $user_to_delete ) :

            // wp_delete_user() accepts another user ID as a second parameter
            // in case you want to reassign the content to an active user
            wp_delete_user( $user_to_delete->ID );

        endforeach;

    }
    add_action( 'admin_init', 'wpse220426_delete_users_by_role' );

?>

Remember to backup your database before as it will run straight after activation without the need to trigger any button. Once it has finished deleting the users, also remeber to deactivate o delete it.