information_schema.column_privileges 学习

本文详细介绍了MySQL数据库中列级权限的实现原理及其在information_schema.column_privileges表中的存储方式。通过具体示例展示了如何查询特定用户的列级权限。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

mysql 的授权是分层次的 实例级 | 库级 | 表级 | 列级 而这些授权信息被保存在了mysql.user | mysql.db | mysql.tables_priv | mysql.column_priv 等表中

而information_schema.column_privileges 表中的信息来自于mysql.column_priv 表

1、information_schema.column_privileges 表中常用的列:

  1、grantee                :用户(对列就相应权限的用户)

  2、table_catalog             :表类型,好像只有一个值 def

  3、table_schema              :表所在的数据库名

  4、table_name              :表名

  5、column_anme             :列名

  6、privilege_type             :权限类型

  7、is_grantable             :是否可以把权限授予别人

 

2、例子:

查看一条对列的授权在information_schema.column_privileges 表中对应怎样的数据

2.1 授权:

GRANT SELECT (x) ON `tempdb`.`t` TO 'guest'@'127.0.0.1'

2.2 查看information_schema.column_privileges 表

select * from information_schema.column_privileges;


+---------------------+---------------+--------------+------------+-------------+----------------+--------------+
| GRANTEE             | TABLE_CATALOG | TABLE_SCHEMA | TABLE_NAME | COLUMN_NAME | PRIVILEGE_TYPE | IS_GRANTABLE |
+---------------------+---------------+--------------+------------+-------------+----------------+--------------+
| 'guest'@'127.0.0.1' | def           | tempdb       | t          | x           | SELECT         | NO           |
+---------------------+---------------+--------------+------------+-------------+----------------+--------------+

 

转载于:https://www.cnblogs.com/JiangLe/p/5793689.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值