GRANT (Procedure)

Grants privileges on a procedure to a database user or role. Only the superuser can grant privileges to a procedure. To grant privileges to a schema containing the procedure, users must have USAGE privileges. See GRANT (Schema).

Important: External procedures that you create with CREATE PROCEDURE are always run with Linux dbadmin privileges. If a dbadmin or pseudosuperuser grants a non-dbadmin permission to run a procedure using GRANT (Procedure), be aware that the non-dbadmin user runs the procedure with full Linux dbadmin privileges.

Syntax

GRANT { EXECUTE | ALL [ PRIVILEGES ] }
   ON PROCEDURE  [ [schema.]procedure-name [, ...] 
   ( [ argname ] argtype [,... ] )
   TO { username | role | PUBLIC } [, ...] 

Parameters

{ EXECUTE | ALL } 

The type of privilege to grant the procedure. Either EXECUTE or ALL are applicable privileges to grant. When using more than one schema, specify the schema that contains the procedure.

PRIVILEGES [Optional] For SQL standard compatibility and is ignored.
schema-name

Specifies a schema. If multiple schemas are defined in the database, include the schema name. For example:

myschema.thisDbObject
procedure-name

The SQL or User Defined procedure on which to grant the privilege. If using more than one schema, you must specify the schema that contains the procedure.

argname

The optional argument name for the procedure.

argtype

The required argument data type or types of the procedure.

{ username | role | PUBLIC }[,...]

The recipient of the procedure privileges, which can be one or more users, one or more roles, or all users and roles (PUBLIC).

  • username—Indicates a specific user
  • role—Specifies a particular role
  • PUBLIC—Indicates that all users and roles have granted privileges to the procedure.

Example

The following command grants EXECUTE privileges on the tokenize procedure to users Bob and Jules, and to the Operator role:

=> GRANT EXECUTE ON PROCEDURE tokenize(varchar) TO Bob, Jules, Operator;