REGISTER STORAGE UNIT
Description
The REGISTER STORAGE UNIT syntax is used to register storage unit for the currently selected logical database.
Syntax
RegisterStorageUnit ::=
'REGISTER' 'STORAGE' 'UNIT' ifNotExists? storageUnitsDefinition (',' checkPrivileges)?
storageUnitsDefinition ::=
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
checkPrivileges ::=
'CHECK_PRIVILEGES' '=' privilegeType (',' privilegeType)*
privilegeType ::=
identifierSupplement
- Before registering storage units, ensure that the target logical database exists and is selected for the current connection;
- Confirm that the registered storage unit can be connected normally, otherwise it will not be added successfully;
storageUnitNameis case-sensitive;storageUnitNameneeds to be unique within the current database;storageUnitNamename only allows letters, numbers and_, and must start with a letter;PROPERTIESis optional, used to customize connection pool properties,keymust be the same as the connection pool property name;CHECK_PRIVILEGEScan be specified to check privileges of the storage unit user. The supported types ofprivilegeTypeareSELECT,XA,PIPELINE, andNONE. The default value isSELECT. WhenNONEis included in the type list, the privilege check is skipped.
Example
- Register storage unit using HOST & PORT method
REGISTER STORAGE UNIT ds_0 (
HOST="127.0.0.1",
PORT=3306,
DB="db_0",
USER="root",
PASSWORD="root"
);- Register storage unit and set connection pool properties using HOST & PORT method
REGISTER STORAGE UNIT ds_1 (
HOST="127.0.0.1",
PORT=3306,
DB="db_1",
USER="root",
PASSWORD="root",
PROPERTIES("maximumPoolSize"=10)
);- Register storage unit and set connection pool properties using URL method
REGISTER STORAGE UNIT ds_2 (
URL="jdbc:mysql://127.0.0.1:3306/db_2?serverTimezone=UTC&useSSL=false&allowPublicKeyRetrieval=true",
USER="root",
PASSWORD="root",
PROPERTIES("maximumPoolSize"=10,"idleTimeout"=30000)
);- Register storage unit with
ifNotExistsclause
REGISTER STORAGE UNIT IF NOT EXISTS ds_0 (
HOST="127.0.0.1",
PORT=3306,
DB="db_0",
USER="root",
PASSWORD="root"
);- Check
SELECT,XAandPIPELINEprivileges when registering
REGISTER STORAGE UNIT ds_3 (
URL="jdbc:mysql://127.0.0.1:3306/db_3?serverTimezone=UTC&useSSL=false&allowPublicKeyRetrieval=true",
USER="root",
PASSWORD="root",
PROPERTIES("maximumPoolSize"=10,"idleTimeout"=30000)
), CHECK_PRIVILEGES=SELECT,XA,PIPELINE;Reserved word
REGISTER, STORAGE, UNIT, HOST, PORT, DB, USER, PASSWORD, PROPERTIES, URL, CHECK_PRIVILEGES