使用INFORMATION_SCHEMA.SCHEMA_PRIVILEGES显示用户的所有补助-
select *from INFORMATION_SCHEMA.SCHEMA_PRIVILEGES;
让我们实现以上语法以显示用户的所有授权-
mysql> select *from INFORMATION_SCHEMA.SCHEMA_PRIVILEGES;
这将产生以下输出-
+-----------------------------+---------------+--------------------+-------------------------+--------------+ | GRANTEE | TABLE_CATALOG | TABLE_SCHEMA | PRIVILEGE_TYPE | IS_GRANTABLE | +-----------------------------+---------------+--------------------+-------------------------+--------------+ | 'mysql.sys'@'localhost' | def | sys | TRIGGER | NO | | 'Adam Smith'@'localhost' | def | test | SELECT | NO | | 'Adam Smith'@'localhost' | def | test | INSERT | NO | | 'Adam Smith'@'localhost' | def | test | UPDATE | NO | | 'Adam Smith'@'localhost' | def | test | DELETE | NO | | 'Adam Smith'@'localhost' | def | test | CREATE | NO | | 'Adam Smith'@'localhost' | def | test | DROP | NO | | 'Adam Smith'@'localhost' | def | test | REFERENCES | NO | | 'Adam Smith'@'localhost' | def | test | INDEX | NO | | 'Adam Smith'@'localhost' | def | test | ALTER | NO | | 'Adam Smith'@'localhost' | def | test | CREATE TEMPORARY TABLES | NO | | 'Adam Smith'@'localhost' | def | test | LOCK TABLES | NO | | 'Adam Smith'@'localhost' | def | test | EXECUTE | NO | | 'Adam Smith'@'localhost' | def | test | CREATE VIEW | NO | | 'Adam Smith'@'localhost' | def | test | SHOW VIEW | NO | | 'Adam Smith'@'localhost' | def | test | CREATE ROUTINE | NO | | 'Adam Smith'@'localhost' | def | test | ALTER ROUTINE | NO | | 'Adam Smith'@'localhost' | def | test | EVENT | NO | | 'Adam Smith'@'localhost' | def | test | TRIGGER | NO | | 'David'@'localhost' | def | test | SELECT | NO | | 'David'@'localhost' | def | test | INSERT | NO | | 'David'@'localhost' | def | test | UPDATE | NO | | 'David'@'localhost' | def | test | DELETE | NO | | 'David'@'localhost' | def | test | CREATE | NO | | 'David'@'localhost' | def | test | REFERENCES | NO | | 'David'@'localhost' | def | test | ALTER | NO | | 'mysql.session'@'localhost' | def | performance_schema | SELECT | NO | | 'Robert'@'%' | def | sample | SELECT | YES | | 'Robert'@'%' | def | sample | INSERT | YES | | 'Robert'@'%' | def | sample | UPDATE | YES | | 'Robert'@'%' | def | sample | DELETE | YES | | 'Robert'@'%' | def | sample | CREATE | YES | | 'Robert'@'%' | def | sample | DROP | YES | | 'Robert'@'%' | def | sample | REFERENCES | YES | | 'Robert'@'%' | def | sample | INDEX | YES | | 'Robert'@'%' | def | sample | ALTER | YES | | 'Robert'@'%' | def | sample | CREATE TEMPORARY TABLES | YES | | 'Robert'@'%' | def | sample | LOCK TABLES | YES | | 'Robert'@'%' | def | sample | EXECUTE | YES | | 'Robert'@'%' | def | sample | CREATE VIEW | YES | | 'Robert'@'%' | def | sample | SHOW VIEW | YES | | 'Robert'@'%' | def | sample | CREATE ROUTINE | YES | | 'Robert'@'%' | def | sample | ALTER ROUTINE | YES | | 'Robert'@'%' | def | sample | EVENT | YES | | 'Robert'@'%' | def | sample | TRIGGER | YES | | 'Robert'@'%' | def | web | EXECUTE | NO | +-----------------------------+---------------+--------------------+-------------------------+--------------+ 46 rows in set (0.00 sec)