Project: ShardingSphere (App Definition and Development / Database)
File: mix.en.md

+++ title = "Mixed Rules" weight = 10 +++ ShardingSphere provides a variety of features, such as data sharding, read/write splitting, and data encryption. These features can be used independently or in combination. Below, you will find the parameters' explanation and configuration samples based on YAML. ```yaml rules: !SHARDING tables: <logictablename>: # Logical table name: actualDataNodes: # consists of logical data source name plus table name (refer to Inline syntax rules) tableStrategy: # Table shards strategy. The same as database shards strategy standard: shardingColumn: # Sharding column name shardingAlgorithmName: # Sharding algorithm name keyGenerateStrategy: column: # Auto-increment column name. By default, the auto-increment primary key generator is not used. keyGeneratorName: # Distributed sequence algorithm name defaultDatabaseStrategy: standard: shardingColumn: # Sharding column name shardingAlgorithmName: # Sharding algorithm name shardingAlgorithms: <shardingalgorithmname>: # Sharding algorithm name type: INLINE props: algorithm-expression: # INLINE expression torderinline: type: INLINE props: algorithm-expression: # INLINE expression keyGenerators: <keygeneratealgorithm_name> (+): # Distributed sequence algorithm name type: # Distributed sequence algorithm type props: # Property configuration of distributed sequence algorithm !ENCRYPT encryptors: <encryptalgorithmname> (+): # Encryption and decryption algorithm name type: # Encryption and decryption algorithm type props: # Encryption and decryption algorithm property configuration <encryptalgorithmname> (+): # Encryption and decryption algorithm name type: # Encryption and decryption algorithm type tables: <table_name>: # Encryption table name columns: <column_name> (+): # Encrypt logic column name cipher: name: # Cipher column name encryptorName: # Cipher encrypt algorithm name assistedQuery (?): name: # Assisted query column name encryptorName: # Assisted query encrypt algorithm name likeQuery (?): name: # Like query column name encryptorName: # Like query encrypt algorithm name ``` ```yaml rules: !SHARDING tables: t_order: actualDataNodes: replicads${0..1}.torder${0..1} tableStrategy: standard: shardingColumn: order_id shardingAlgorithmName: torderinline keyGenerateStrategy: column: order_id keyGeneratorName: snowflake defaultDatabaseStrategy: standard: shardingColumn: user_id shardingAlgorithmName: database_inline shardingAlgorithms: database_inline: type: INLINE props: algorithm-expression: replicads${user_id % 2} torderinline: type: INLINE props: algorithm-expression: torder${order_id % 2} torderitem_inline: type: INLINE props: algorithm-expression: torderitem${orderid % 2} keyGenerators: snowflake: type: SNOWFLAKE !ENCRYPT encryptors: aes_encryptor: type: AES props: aes-key-value: 123456abc assisted_encryptor: type: MD5 like_encryptor: type: CHARDIGESTLIKE tables: t_encrypt: columns: user_id: cipher: name: user_cipher encryptorName: aes_encryptor assistedQuery: name: assistedqueryuser encryptorName: assisted_encryptor likeQuery: name: likequeryuser encryptorName: like_encryptor order_id: cipher: name: order_cipher encryptorName: aes_encryptor ```