> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-fix-nav-issues.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 一般的なRBACクエリ

> ユーザーに特定の権限を付与する際に役立つクエリ。

<div id="introduction">
  ## はじめに
</div>

以下は、ユーザーに特定の権限を付与する際によく使用されるクエリです。

<div id="how-do-i-grant-the-same-permissions-as-the-current-user-to-another-user">
  ## 現在のユーザーと同じ権限を別のユーザーに付与するにはどうすればよいですか？
</div>

```sql theme={null}
GRANT CURRENT GRANTS ON *.* TO another_user;
```

<div id="how-do-i-grant-a-specific-permission-to-a-user-based-on-the-grants-of-the-current-user">
  ## 現在のユーザーに付与されている権限に基づいて、ユーザーに特定の権限を付与するにはどうすればよいですか？
</div>

以下の例では、`another_user` は現在のユーザーが持つすべてのデータベースとテーブルに対して `SELECT` コマンドを実行できるようになります。

```sql theme={null}
GRANT CURRENT GRANTS(SELECT ON *.*) TO another_user;
```

<div id="how-do-i-grant-a-specific-permission-to-a-user-for-a-specific-database-based-on-the-grants-of-the-current-user">
  ## 現在のユーザーに付与されている権限に基づいて、特定のデータベースに対する特定の権限をユーザーに付与するにはどうすればよいですか？
</div>

以下の例では、`another_user` は `my_database` 内のすべてのテーブルに対して `INSERT` コマンドを実行できます。

```sql theme={null}
GRANT INSERT ON my_database.* TO another_user;
```

<div id="how-do-i-give-access-to-all-grants-for-a-specific-user-based-on-the-default-user">
  ## `default`ユーザーを基に、特定のユーザーに同じすべての権限を付与するにはどうすればよいですか？
</div>

```sql theme={null}
GRANT default_role TO another_user;
```
