# Role Authorization Tables

__*zz-BGL*__
__*zz-Jeff*__

+ The `RBAC` system introduces two system privilege tables for roles:
  + **`mysql.role_edges:`** Records the authorization relationship of the role and user
  + **`mysql.default_roles:`** Records default roles of each user
+ For example:
```
tidb> SELECT * FROM ~!@mysql.role_edges@!~;
+-----------+-----------+-----------+-----------+-------------------+
| FROM_HOST | FROM_USER | TO_HOST   | TO_USER   | WITH_ADMIN_OPTION |
+-----------+-----------+-----------+-----------+-------------------+
| %         | r_clerk   | %         | r_manager | N                 |
| %         | r_clerk   | %         | scott     | N                 |
| %         | r_manager | %         | jack      | N                 |
+-----------+-----------+-----------+-----------+-------------------+
5 rows in set (0.00 sec)

tidb> SELECT * FROM ~!@mysql.default_roles@!~ WHERE user='todd' AND host='%';
+------+------+-------------------+-------------------+
| HOST | USER | DEFAULT_ROLE_HOST | DEFAULT_ROLE_USER |
+------+------+-------------------+-------------------+
| %    | todd | %                 | r_default_dev     |
+------+------+-------------------+-------------------+
1 row in set (0.00 sec)
```

-------------------------------------------------------------
`mysql.role_edges`:
- `FROM_HOST` and `FROM_USER` indicate the role's host name and role name respectively.
- `TO_HOST` and `TO_USER` indicate the host name and user name of the user to which a role is granted.

`mysql.default_roles`:
- `HOST` and `USER` indicate the user's host name and user name respectively.
- `DEFAULT_ROLE_HOST` and `DEFAULT_ROLE_USER` indicate the host name and user name of the default role respectively.
