Note
- In OceanBase Database V4.3.x, this view is introduced since V4.3.1.
- In OceanBase Database V4.2.x, this view is introduced since V4.2.3.
Purpose
The mysql.columns_priv view displays the column privileges granted to a user.
Columns
| Column | Type | Nullable? | Description |
|---|---|---|---|
| Host | varchar(255) | NO | The name of the host to which the privilege is to be granted. The value % indicates that the privilege is granted to all hosts. |
| Db | varchar(128) | NO | The name of the database. |
| User | varchar(128) | NO | The username. |
| Table_name | varchar(128) | NO | The name of the table. |
| Column_name | varchar(128) | NO | The name of the column. |
| Column_priv | varchar(31) | NO | The column privileges, such as SELECT, INSERT, and UPDATE. |
| Timestamp | datetime | YES | The timestamp indicating the time when the privilege was last modified. |
Sample query
Grant the
u1user theSELECTprivilege on thec1column and theUPDATEprivilege on thec2column in thet1table.obclient [mysql]> grant select(c1), update(c2) on t1 to u1;Query the column privileges granted to the
u1user.obclient [mysql]> select * from mysql.columns_priv;The query result is as follows:
+------+------+------+------------+-------------+-------------+---------------------+ | Host | Db | User | Table_name | Column_name | Column_priv | Timestamp | +------+------+------+------------+-------------+-------------+---------------------+ | % | test | u1 | t1 | c2 | Update | 2024-04-24 14:38:20 | | % | test | u1 | t1 | c1 | Select | 2024-04-24 14:38:20 | +------+------+------+------------+-------------+-------------+---------------------+ 2 rows in set (0.092 sec)