Note
This view was introduced in V4.3.3 for V4.3x and V4.2.4 for V4.2.x.
Purpose
The role_column_grants view displays the column privileges granted to activated roles for the current user and other roles granted to the activated roles.
Columns
| Column | Type | Nullable? | Description |
|---|---|---|---|
| GRANTOR | null | NO | The username of the account that granted the role. In OceanBase Database, this value is always NULL. |
| GRANTOR_HOST | null | NO | The host of the account that granted the role. In OceanBase Database, this value is always NULL. |
| GRANTEE | varchar(32) | NO | The username of the account corresponding to the role. |
| GRANTEE_HOST | varchar(255) | NO | The hostname of the account corresponding to the role. |
| TABLE_CATALOG | varchar(3) | NO | The name of the catalog to which the role is granted. This value is always def. |
| TABLE_SCHEMA | varchar(64) | NO | The name of the database to which the table is assigned. |
| TABLE_NAME | varchar(64) | NO | The name of the table. |
| COLUMN_NAME | varchar(64) | NO | The name of the column. |
| PRIVILEGE_TYPE | varchar(31) | NO | The granted privilege. This value can be any privilege granted at the column level of the specified table. Each row displays all privileges granted to a column. |
| IS_GRANTABLE | varchar(3) | NO | Whether the privileges granted to the role can be granted to other users. |
Sample query
Create a role and a table.
obclient [test]> CREATE ROLE employee;obclient [test]> CREATE TABLE tbl1(c1 int, c2 int, c3 int);Grant column-level privileges to the role.
obclient [test]> GRANT INSERT (c1, c2), SELECT (c1) ON test.tbl1 TO employee;Grant the role to a user.
obclient [test]> GRANT employee TO user1;Connect to the database as the
user1user.Activate the
employeerole in the current session.obclient [test]> SET ROLE employee;View the column privileges granted to activated roles for the current user.
obclient [test]> USE information_schema;obclient [test]> SELECT * FROM information_schema.role_column_grants;The query result is as follows:
+---------+--------------+----------+--------------+---------------+--------------+------------+-------------+----------------+--------------+ | GRANTOR | GRANTOR_HOST | GRANTEE | GRANTEE_HOST | TABLE_CATALOG | TABLE_SCHEMA | TABLE_NAME | COLUMN_NAME | PRIVILEGE_TYPE | IS_GRANTABLE | +---------+--------------+----------+--------------+---------------+--------------+------------+-------------+----------------+--------------+ | NULL | NULL | employee | % | def | test | tbl1 | c1 | Select,Insert | NO | | NULL | NULL | employee | % | def | test | tbl1 | c2 | Insert | NO | +---------+--------------+----------+--------------+---------------+--------------+------------+-------------+----------------+--------------+ 2 rows in set