Skip to main content

SHOW ENCRYPTKEY

Description​

View all custom keys under the database. If the user specifies a database, check the corresponding database, otherwise directly query the database where the current session is located.

Syntax​

SHOW ENCRYPTKEYS [ { IN | FROM } <db> ] [ LIKE '<key_pattern>']

Optional Parameters​

1. <db>

Name of the target database.
Example: db1 (in key names like db1.my_key).

2. <key_pattern>

Pattern parameter for filtering key names (supports wildcard matching).

Return Value​

ColumnDescription
EncryptKey NameName of the key
EncryptKey StringValue of the key

Access Control Requirements​

The user executing this SQL command must have the following minimum privileges:

PrivilegeObjectNotes
ADMIN_PRIVUser / RoleMust hold the ADMIN_PRIV privilege on the target user/role to view encryption keys

Usage Notes​

If a database is explicitly specified, the system will query encryption keys within the designated database. Otherwise, it automatically queries keys in the current session's database.

Example​

  • List all custom keys in the current session's database.

    SHOW ENCRYPTKEYS;
    +-----------------+-------------------+
    | EncryptKey Name | EncryptKey String |
    +-----------------+-------------------+
    | testdb.test_key | ABCD123456789 |
    +-----------------+-------------------+
  • List all custom keys in a specified database.

    SHOW ENCRYPTKEYS FROM example_db ;
    +---------------------+-------------------+
    | EncryptKey Name | EncryptKey String |
    +---------------------+-------------------+
    | example_db.my_key | ABCD123456789 |
    | example_db.test_key | ABCD123456789 |
    +---------------------+-------------------+
  • Filter keys by name pattern in a specified database.

    SHOW ENCRYPTKEYS FROM example_db LIKE "%my%";
    +-------------------+-------------------+
    | EncryptKey Name | EncryptKey String |
    +-------------------+-------------------+
    | example_db.my_key | ABCD123456789 |
    +-------------------+-------------------+