Use the SHOW PRIVILEGES statement to query the permissions of all users. The results help you verify whether the permissions granted to a user are appropriate. This lets you manage database permissions and reduce security risks.
Engine and version support
The SHOW PRIVILEGES statement applies to LindormTable and LindormTSDB.
The SHOW PRIVILEGES statement is supported by LindormTable 2.4.3 and later.
This statement is supported by all versions of LindormTSDB.
Syntax
show_privileges_statement ::= SHOW PRIVILEGESUsage notes
The SHOW PRIVILEGES statement requires the ADMIN permission. For more information about how to grant the ADMIN permission, see GRANT. For more information about permissions, see Permission classification.
Returned result set
Column | Type | Description |
user | VARCHAR | The username that is granted the permission. |
global privileges | VARCHAR | The collection of GLOBAL-level permissions that the user has. |
database privileges | VARCHAR | The collection of DATABASE-level (Namespace-level) permissions that the user has. |
table privileges | VARCHAR | The collection of TABLE-level permissions that the user has. Note LindormTSDB does not support TABLE-level authorization. The result is empty. |
To facilitate application processing, the data in the permission columns is returned in JSON format. The JSON structure is as follows:
key: The name of the access object, such as a database name or a table name. The key for global permissions is fixed as
GLOBAL.value: A list of permissions.
If a user has no permissions at a specific level, the value is a string that represents an empty JSON object.
Examples
Show the permissions of all users.
SHOW PRIVILEGES;The following result is returned:
+-------+-------------------------------------------------------+-------------------------------------------------+--------------------------------------------------------------+
| user | global privileges | database privileges | table privileges |
+-------+-------------------------------------------------------+-------------------------------------------------+--------------------------------------------------------------+
| User1 | {"actions":["READ"]} | {"Db1":{"actions":["WRITE"],"namespace":"Db1"}} | {"Db1.Table1":{"actions":["READ"],"tableName":"Db1.Table1"}} |
+-------+-------------------------------------------------------+-------------------------------------------------+--------------------------------------------------------------+