SHOW USERS
Introduced or updated: v1.2.957
Lists the SQL users visible to the current session.
Visibility
SHOW USERS and direct queries of system.users use the same visibility rules:
- A session with the global
GRANTprivilege can list all users in the tenant. - Other sessions see only the current user's matching username and hostname. A different account with the same username but another hostname is not visible.
- Configured users follow the same identity filter. A configured user has hostname
%.
This filtering also applies to SQL sessions in Databend Cloud. An incomplete list does not mean that the other users were deleted.
Syntax
SHOW USERS
Examples
Run this example with an administrative session that has global GRANT to see both users in the sample output.
CREATE NETWORK POLICY my_network_policy ALLOWED_IP_LIST=('192.168.100.0/24');
CREATE PASSWORD POLICY my_password_policy
PASSWORD_MIN_LENGTH = 12
PASSWORD_MAX_LENGTH = 24
PASSWORD_MIN_UPPER_CASE_CHARS = 2
PASSWORD_MIN_LOWER_CASE_CHARS = 2
PASSWORD_MIN_NUMERIC_CHARS = 2
PASSWORD_MIN_SPECIAL_CHARS = 2
PASSWORD_MIN_AGE_DAYS = 1
PASSWORD_MAX_AGE_DAYS = 30
PASSWORD_MAX_RETRIES = 3
PASSWORD_LOCKOUT_TIME_MINS = 30
PASSWORD_HISTORY = 5
COMMENT = 'test comment';
CREATE USER eric IDENTIFIED BY '123ABCabc$$123' WITH SET PASSWORD POLICY='my_password_policy', SET NETWORK POLICY='my_network_policy';
SHOW USERS;
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ name │ hostname │ auth_type │ is_configured │ default_role │ roles │ disabled │ network_policy │ password_policy │ must_change_password │
├────────┼──────────┼──────────────────────┼───────────────┼───────────────┼───────────────┼──────────┼───────────────────┼────────────────────┼──────────────────────┤
│ eric │ % │ double_sha1_password │ NO │ │ │ false │ my_network_policy │ my_password_policy │ NULL │
│ root │ % │ no_password │ YES │ account_admin │ account_admin │ false │ NULL │ NULL │ NULL │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘