Skip to content

GRANT EXECUTE statement

In Yellowbrick, you can grant execution rights on functions to a user (or role) using the GRANT EXECUTE statement. This is useful when you want to give a user the ability to run a function without granting them broader access to the database.

Syntax

  • For granting the execute permission on a function:
sql
GRANT EXECUTE 
ON FUNCTION your_function_name(parameter_type1, parameter_type2, ...) 
TO user_name;
  • For all functions in a schema:
sql
GRANT EXECUTE 
ON ALL FUNCTIONS 
IN SCHEMA schema_name TO user_name;

Examples

Grant Execute on a Specific Function

sql
--Grant execute permission on a function named `add_numbers(INT4, INT4)` to a user named `john_smith`
GRANT EXECUTE 
ON FUNCTION add_numbers(INT4, INT4)
TO john_smith;

Grant Execute on All Functions in a Schema

sql
-- Grant a user execute permissions on all functions within a specific schema, such as `public`
GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA public TO john_smith;

After executing the GRANT EXECUTE command, john_smith will have the necessary permissions to execute the specified function(s) in your Yellowbrick database.