Usage
This chapter will introduce how to use DistSQL to manage resources and rules in a distributed database.
The examples in this chapter use ShardingSphere-Proxy. For execution with ShardingSphere-JDBC and its limitations, see Java API: Execute DistSQL.
Pre-work
Use MySQL as example, can replace to other databases.
- Start the MySQL service;
- Create to be registered MySQL databases;
- Create role and user in MySQL with creation permission for ShardingSphere-Proxy;
- Start Zookeeper service;
- Add
modeandauthenticationconfigurations toglobal.yaml; - Start ShardingSphere-Proxy;
- Use SDK or terminal connect to ShardingSphere-Proxy.
Create Logic Database
- Create logic database
CREATE DATABASE foo_db;- Use newly created logic database
USE foo_db;Resource Operation
More details please see concentrate rule examples.
Rule Operation
More details please see concentrate rule examples.
Notice
- Currently,
DROP DATABASEwill only remove thelogical distributed database, not the user’s actual database; DROP TABLEwill delete all logical fragmented tables and actual tables in the database;CREATE DATABASEwill only create alogical distributed database, so users need to create actual databases in advance.