Product Documentation

SQL Reference Guide

Previous Topic

Next Topic

GRANT

Description

When RBAC is active, grants various privileges to the specified role(s) or user group for the database. There are different forms of the GRANT statement for multiple purposes:

  • To grant privileges on the specified tables or view
  • To grant the privilege to execute the specified stored procedure

To grant or remove privileges for system administration (DBA) or general creation (RESOURCE), simply enable/disable database-level permissions.

Syntax

GRANT { privilege [ , privilege ] ... | ALL [ PRIVILEGES ] }

ON table_name

TO { { user_name | usergroup_name } [ , {user_name | usergroup_name} ] ... | PUBLIC }

GRANT EXECUTE ON procedure_name

TO { { user_name | usergroup_name } [ , { user_name | usergroup_name } ] ... | PUBLIC } ;

privilege ::

{ SELECT | INSERT | DELETE | ALTER | INDEX | UPDATE }

Arguments

DBA

Allows the specified role to create, access, modify, or delete any database object and grant other users any privileges.

RESOURCE

Allows the specified role to issue CREATE statements. The RESOURCE privilege does not allow users to issue DROP statements on database objects. Only the object's owner and users with the DBA privilege can drop database objects.

SELECT

Allows the specified role to read data in the table or view.

INSERT

Allows the specified role to add new rows to the table or view.

DELETE

Allows the specified role to delete rows in the table or view

ALTER

Allows the specified role to modify the table or view

UPDATE

Allows the specified users to modify existing rows in the table or view.

ALL

Grants all privileges for the table or view.

ON table_name

The table or view for which FairCom DB SQL grants the specified privileges.

EXECUTE ON procedure_name

Allows execution of the specified stored procedure.

TO role_name [ , role_name ] ...

The list of roles for which FairCom DB SQL grants the specified privileges.

TO PUBLIC

Grants the specified privileges to any user with access to the system.

Examples

Note: You must commit, or turn on auto commit, to save your changes. For example, ISQL defaults to auto commit off, so if you grant a permission and exit, your changes are discarded.

GRANT RESOURCE TO user1;

GRANT SELECT ON custmaster TO odbc_group;

GRANT ALTER ON cust_view TO dbuser1 ;

GRANT SELECT ON newcustomers TO dbuser2 ;

GRANT EXECUTE ON sample_proc TO searle;

commit;

Authorization

The user granting DBA or RESOURCE privileges must have the DBA privilege.

The user granting privileges on a table must have any of the following privileges:

  • DBA privilege
  • Ownership of the table

    SQL Compliance

    SQL-92, ODBC Core SQL grammar. Extensions: ALTER, RESOURCE, DBA privileges

    Environment

    Embedded SQL, interactive SQL, ODBC applications

    Related Statements

    REVOKE

See also

Grant (RBAC off)

TOCIndex