Note
- In MySQL 4.3.x, this view was introduced in MySQL 4.3.1.
- In MySQL 4.2.x, this view was introduced in MySQL 4.2.3.
Description
The mysql.columns_priv view is used to view the column privileges granted to users.
Fields
Field |
Type |
NULL? |
Description |
|---|---|---|---|
| Host | varchar(255) | NO | The hostname of the host to 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 username to which the privilege is granted. |
| Table_name | varchar(128) | NO | The table name. |
| Column_name | varchar(128) | NO | The column name. |
| Column_priv | varchar(31) | NO | The column privileges. Valid values: SELECT, INSERT, UPDATE, etc. |
| Timestamp | datetime | YES | The timestamp when the privilege was last changed. |
Examples
Grant the SELECT privilege on column c1 and the UPDATE privilege on column c2 of table t1 to user u1.
obclient [mysql]> grant select(c1), update(c2) on t1 to u1;View 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)
