What is the diiference between CREATE ROLE and GRANT?

For instance, CREATE ROLE analyst WITH NOSUPERUSER LOGIN CREATEDB;
and GRANT USAGE, CREATE ON SCHEMA marketing TO analyst;.

If a user has a role defined with CREATE ROLE where it is specified that they can create a database, wouldn’t they be able to create on any schema in the DBs they created?

One creates a role and then assigns users to the role and grants permissions to it (a group of privileges created and granted to said user).

See:
https://www.geeksforgeeks.org/sql-creating-roles/

1 Like