SQL$HELP_OLD72.HLB  —  GRANT_ANSI, Examples
    Example 1: Using PUBLIC as a wildcard

    This example shows that PUBLIC translates to [*,*] and can be
    used to grant access to the database for all users.

    SQL> show protection on database rdb$dbhandle;
    Protection on Alias RDB$DBHANDLE
    [RDB,DOCS]:
      With Grant Option:        SELECT,INSERT,UPDATE,DELETE,SHOW,CREATE,ALTER,DROP,
                                DBCTRL,OPERATOR,DBADM,SECURITY,DISTRIBTRAN
      Without Grant Option:     NONE
    [*,*]:
      With Grant Option:        NONE
      Without Grant Option:     NONE
    SQL> grant select on database alias rdb$dbhandle to public;
    SQL> show protection on database rdb$dbhandle;
    Protection on Alias RDB$DBHANDLE
    [RDB,DOCS]:
      With Grant Option:        SELECT,INSERT,UPDATE,DELETE,SHOW,CREATE,ALTER,DROP,
                                DBCTRL,OPERATOR,DBADM,SECURITY,DISTRIBTRAN
      Without Grant Option:     NONE
    [*,*]:
      With Grant Option:        NONE
      Without Grant Option:     SELECT
    SQL> commit;

    Example 2: Granting a privilege with the WITH GRANT OPTION
    clause.

    This example shows how the WITH GRANT OPTION causes Rdb to
    maintain a separate list of privileges that were granted by a
    user with ability to GRANT to others. This extra information
    is queries using the SHOW USERS WITH and SHOW USERS GRANTING
    commands.

    SQL> show protection on table EMPLOYEES;
    Protection on Table EMPLOYEES
    [RDB,DOCS]:
      With Grant Option:        SELECT,INSERT,UPDATE,DELETE,SHOW,CREATE,ALTER,DROP,
                                DBCTRL,REFERENCES
      Without Grant Option:     NONE
    [*,*]:
      With Grant Option:        NONE
      Without Grant Option:     NONE
    SQL> grant delete on employees to freeman with grant option;
    SQL>
    SQL> show protection on table EMPLOYEES;
    Protection on Table EMPLOYEES
    [RDB,FREEMAN]:
      With Grant Option:        DELETE
      Without Grant Option:     NONE
    [RDB,DOCS]:
      With Grant Option:        SELECT,INSERT,UPDATE,DELETE,SHOW,CREATE,ALTER,DROP,
                                DBCTRL,REFERENCES
      Without Grant Option:     NONE
    [*,*]:
      With Grant Option:        NONE
      Without Grant Option:     NONE
    SQL>
    SQL> -- Show the list of users who will loose their DELETE
    SQL> -- privilege if the privilege is taken away from DOCS
    SQL>
    SQL> show users with delete on employees from DOCS;
    Users granted privileges on table EMPLOYEES by [RDB,DOCS]
    [RDB,FREEMAN]
    [RDB,DOCS]
        [RDB,FREEMAN]
    SQL>
    SQL> -- Check if anyone on the list has given DELETE to anyone else
    SQL>
    SQL> show users granting delete on employees to PUBLIC;
    Users granting privileges on table EMPLOYEES to [*,*]
    No users found
    SQL>

    Example 3: Granting column privileges

    This example shows the two forms of the GRANT column statement
    and the effects it has on the target columns.

    SQL> -- First show existing column protections
    SQL>
    SQL> show protection on column CANDIDATES.FIRST_NAME;
    Protection on Column CANDIDATES.FIRST_NAME
    SQL> show protection on column CANDIDATES.CANDIDATE_STATUS;
    Protection on Column CANDIDATES.CANDIDATE_STATUS
    SQL>
    SQL> -- Show alternate formats for the GRANT column statement
    SQL>
    SQL> grant update (CANDIDATE_STATUS) on table CANDIDATES to freeman;
    SQL> grant update on column CANDIDATES.FIRST_NAME to freeman;
    SQL>
    SQL> -- Show the effects of the GRANT statements
    SQL>
    SQL> show protection on column candidates.FIRST_NAME;
    Protection on Column CANDIDATES.FIRST_NAME
    [RDB,FREEMAN]:
      With Grant Option:        NONE
      Without Grant Option:     UPDATE
    [*,*]:
      With Grant Option:        NONE
      Without Grant Option:     NONE
    SQL> show protection on column candidates.CANDIDATE_STATUS;
    Protection on Column CANDIDATES.CANDIDATE_STATUS
    [RDB,FREEMAN]:
      With Grant Option:        NONE
      Without Grant Option:     UPDATE
    [*,*]:
      With Grant Option:        NONE
      Without Grant Option:     NONE
    SQL>

    Example 4: Granting privileges on a Sequence

    This example shows that the set of privileges granted by ALL for
    sequences is a small subset of those used for other objects such
    as tables and views.

    SQL> create sequence EMPLOYEE_ID_GEN;
    SQL> grant all on sequence EMPLOYEE_ID_GEN to freeman;
    SQL> grant select on sequence EMPLOYEE_ID_GEN to public;
    SQL> show protection on sequence EMPLOYEE_ID_GEN;
    Protection on Sequence EMPLOYEE_ID_GEN
    [RDB,FREEMAN]:
      With Grant Option:        NONE
      Without Grant Option:     SELECT,SHOW,ALTER,DROP,DBCTRL,REFERENCES
    [RDB,DOCS]:
      With Grant Option:        SELECT,SHOW,ALTER,DROP,DBCTRL,REFERENCES
      Without Grant Option:     NONE
    [*,*]:
      With Grant Option:        NONE
      Without Grant Option:     SELECT
    SQL>
Close Help