REGISTER STORAGE UNIT
Description
The REGISTER STORAGE UNIT
syntax is used to register storage unit for the currently selected logical database.
Syntax
Grammar Railroad diagram
RegisterStorageUnit ::=
'REGISTER' 'STORAGE' 'UNIT' ifNotExists? storageUnitDefinition (',' storageUnitDefinition)*
storageUnitDefinition ::=
storageUnitName '(' ('HOST' '=' hostName ',' 'PORT' '=' port ',' 'DB' '=' dbName | 'URL' '=' url) ',' 'USER' '=' user (',' 'PASSWORD' '=' password)? (',' propertiesDefinition)?')'
ifNotExists ::=
'IF' 'NOT' 'EXISTS'
storageUnitName ::=
identifier
hostname ::=
string
port ::=
int
dbName ::=
string
url ::=
string
user ::=
string
password ::=
string
propertiesDefinition ::=
'PROPERTIES' '(' key '=' value (',' key '=' value)* ')'
key ::=
string
value ::=
literal
Supplement
- Before register storage units, please confirm that a database has been created in Proxy, and execute the
use
command to successfully select a database; - Confirm that the registered storage unit can be connected normally, otherwise it will not be added successfully;
storageUnitName
is case-sensitive;storageUnitName
needs to be unique within the current database;storageUnitName
name only allows letters, numbers and_
, and must start with a letter;poolProperty
is used to customize connection pool parameters,key
must be the same as the connection pool parameter name;ifNotExists
clause is used for avoidDuplicate storage unit
error.
Example
- Register storage unit using standard mode
REGISTER STORAGE UNIT ds_0 (
HOST="127.0.0.1",
PORT=3306,
DB="db_1",
USER="root",
PASSWORD="root"
);
- Register storage unit and set connection pool parameters using standard mode
REGISTER STORAGE UNIT ds_0 (
HOST="127.0.0.1",
PORT=3306,
DB="db_1",
USER="root",
PASSWORD="root",
PROPERTIES("maximumPoolSize"=10)
);
- Register storage unit and set connection pool parameters using URL patterns
REGISTER STORAGE UNIT ds_0 (
URL="jdbc:mysql://127.0.0.1:3306/db_2?serverTimezone=UTC&useSSL=false",
USER="root",
PASSWORD="root",
PROPERTIES("maximumPoolSize"=10,"idleTimeout"="30000")
);
- Register storage unit with
ifNotExists
clause
REGISTER STORAGE UNIT IF NOT EXISTS ds_0 (
HOST="127.0.0.1",
PORT=3306,
DB="db_0",
USER="root",
PASSWORD="root"
);
Reserved word
REGISTER
, STORAGE
, UNIT
, HOST
, PORT
, DB
, USER
, PASSWORD
, PROPERTIES
, URL
Related links
当前内容版权归 ShardingSphere 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 ShardingSphere .