Project: ShardingSphere (App Definition and Development / Database)
File: show-encrypt-rule.en.md

+++ title = "SHOW ENCRYPT RULES" weight = 1 +++ The `SHOW ENCRYPT RULES` syntax is used to query encryption rules for a specified database. {{< tabs >}} {{% tab name="Grammar" %}} ```sql ShowEncryptRule::= 'SHOW' 'ENCRYPT' ('RULES' | 'TABLE' 'RULE' ruleName) ('FROM' databaseName)? ruleName ::= identifier databaseName ::= identifier ``` {{% /tab %}} {{% tab name="Railroad diagram" %}} <iframe frameborder="0" name="diagram" id="diagram" width="100%" height="100%"></iframe> {{% /tab %}} {{< /tabs >}} When `databaseName` is not specified, then `DATABASE`is currently used as the default name. If `DATABASE` is not used, you will receive a `No database selected` prompt. | Column | Description | |--|-| | table | Logical table name | | logic_column | Logical column name | | cipher_column | Ciphertext column name | | assistedquerycolumn | Assisted query column name | | likequerycolumn | Like query column name | | encryptor_type | Encryption algorithm type | | encryptor_props | Encryption algorithm parameter | | assistedquerytype | Assisted query algorithm type | | assistedqueryprops | Assisted query algorithm parameter | | likequerytype | Like query algorithm type | | likequeryprops | Like query algorithm parameter | Query encrypt rules for specified database. ```sql SHOW ENCRYPT RULES FROM encrypt_db; ``` ```sql mysql> SHOW ENCRYPT RULES FROM encrypt_db; +--+--++--+-+-+-++-+--++ | table | logiccolumn | ciphercolumn | assistedquerycolumn | likequerycolumn | encryptortype | encryptorprops | assistedquerytype | assistedqueryprops | likequerytype | likequeryprops | +--+--++--+-+-+-++-+--++ | tuser | pwd | pwdcipher | | | AES | aes-key-value=123456abc | | | | | | tencrypt | pwd | pwdcipher | | | AES | aes-key-value=123456abc | | | | | +--+--++--+-+-+-++-+--++ 2 rows in set (0.00 sec) ``` Query encrypt rules for current database. ```sql SHOW ENCRYPT RULES; ``` ```sql mysql> SHOW ENCRYPT RULES; +--+--++--+-+-+-++-+--++ | table | logiccolumn | ciphercolumn | assistedquerycolumn | likequerycolumn | encryptortype | encryptorprops | assistedquerytype | assistedqueryprops | likequerytype | likequeryprops | +--+--++--+-+-+-++-+--++ | tuser | pwd | pwdcipher | | | AES | aes-key-value=123456abc | | | | | | tencrypt | pwd | pwdcipher | | | AES | aes-key-value=123456abc | | | | | +--+--++--+-+-+-++-+--++ 2 rows in set (0.00 sec) ``` Query specified encrypt rule in specified database. ```sql SHOW ENCRYPT TABLE RULE tencrypt FROM encryptdb; ``` ```sql mysql> SHOW ENCRYPT TABLE RULE tencrypt FROM encryptdb; +--+--++--+-+-+-++-+--++ | table | logiccolumn | ciphercolumn | assistedquerycolumn | likequerycolumn | encryptortype | encryptorprops | assistedquerytype | assistedqueryprops | likequerytype | likequeryprops | +--+--++--+-+-+-++-+--++ | tencrypt | pwd | pwdcipher | | | AES | aes-key-value=123456abc | | | | | +--+--++--+-+-+-++-+--++ 1 row in set (0.01 sec) ``` Query specified encrypt rule in current database. ```sql SHOW ENCRYPT TABLE RULE t_encrypt; ``` ```sql mysql> SHOW ENCRYPT TABLE RULE t_encrypt; +--+--++--+-+-+-++-+--++ | table | logiccolumn | ciphercolumn | assistedquerycolumn | likequerycolumn | encryptortype | encryptorprops | assistedquerytype | assistedqueryprops | likequerytype | likequeryprops | +--+--++--+-+-+-++-+--++ | tencrypt | pwd | pwdcipher | | | AES | aes-key-value=123456abc | | | | | +--+--++--+-+-+-++-+--++ 1 row in set (0.01 sec) ``` `SHOW`, `ENCRYPT`, `TABLE`, `RULE`, `RULES`, `FROM`