This chapter will introduce the detailed syntax of DistSQL.
DistSQL (Distributed SQL) is Apache ShardingSphere’s specific SQL, providing additional operation capabilities compared to standard SQL.
Flexible rule configuration and resource management & control capabilities are one of the characteristics of Apache ShardingSphere.
When using 4.x and earlier versions, developers can operate data just like using a database, but they need to configure resources and rules through YAML file (or registry center). However, the YAML file format and the changes brought by using the registry center made it unfriendly to DBAs.
Starting from version 5.x, DistSQL enables users to operate Apache ShardingSphere just like a database, transforming it from a framework and middleware for developers to a database product for DBAs.
DistSQL is divided into RDL, RQL, RAL and RUL.
Resource & Rule Definition Language, is responsible for the definition of resources and rules.
Resource & Rule Query Language, is responsible for the query of resources and rules.
Resource & Rule Administration Language, is responsible for hint, circuit breaker, configuration import and export, scaling control and other management functions.
Resource & Rule Utility Language, is responsible for SQL parsing, SQL formatting, preview execution plan, etc.
Before having DistSQL, users used SQL to operate data while using YAML configuration files to manage ShardingSphere, as shown below:
At that time, users faced the following problems:
With the advent of DistSQL, the operation of ShardingSphere has also changed:
Now, the user experience has been greatly improved:
DistSQL can be used only with ShardingSphere-Proxy, not with ShardingSphere-JDBC for now.
Like standard SQL, DistSQL is recognized by the parsing engine of ShardingSphere. It converts the input statement into an abstract syntax tree and then generates the Statement
corresponding to each grammar, which is processed by the appropriate Handler
.