Note
- This view is available starting with V4.3.1 in V4.3.x.
- This view is available starting with V4.2.3 in V4.2.x.
Purpose
The mysql.columns_priv view displays the column privileges granted to users.
Columns
| Column | Type | Nullable | Description |
|---|---|---|---|
| Host | varchar(255) | NO | The name of the host from which the privilege is granted. If the value is '%', the privilege is granted to all hosts. |
| Db | varchar(128) | NO | The name of the database to which the table belongs. |
| User | varchar(128) | NO | The name of the user to whom the privilege is granted. |
| 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, including Select, Insert, and Update. |
| Timestamp | datetime | YES | The timestamp indicating the last time the privilege was modified. |
Sample query
Grant the SELECT privilege on column c1 of table t1 and the UPDATE privilege on column c2 of table t1 to user u1.
obclient [mysql]> grant select(c1), update(c2) on t1 to u1;Query the column privileges granted to user u1.
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)
