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

  1. RegisterStorageUnit ::=
  2. 'REGISTER' 'STORAGE' 'UNIT' ifNotExists? storageUnitDefinition (',' storageUnitDefinition)*
  3. storageUnitDefinition ::=
  4. storageUnitName '(' ('HOST' '=' hostName ',' 'PORT' '=' port ',' 'DB' '=' dbName | 'URL' '=' url) ',' 'USER' '=' user (',' 'PASSWORD' '=' password)? (',' propertiesDefinition)?')'
  5. ifNotExists ::=
  6. 'IF' 'NOT' 'EXISTS'
  7. storageUnitName ::=
  8. identifier
  9. hostname ::=
  10. string
  11. port ::=
  12. int
  13. dbName ::=
  14. string
  15. url ::=
  16. string
  17. user ::=
  18. string
  19. password ::=
  20. string
  21. propertiesDefinition ::=
  22. 'PROPERTIES' '(' key '=' value (',' key '=' value)* ')'
  23. key ::=
  24. string
  25. value ::=
  26. 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 avoid Duplicate storage unit error.

Example

  • Register storage unit using standard mode
  1. REGISTER STORAGE UNIT ds_0 (
  2. HOST="127.0.0.1",
  3. PORT=3306,
  4. DB="db_1",
  5. USER="root",
  6. PASSWORD="root"
  7. );
  • Register storage unit and set connection pool parameters using standard mode
  1. REGISTER STORAGE UNIT ds_0 (
  2. HOST="127.0.0.1",
  3. PORT=3306,
  4. DB="db_1",
  5. USER="root",
  6. PASSWORD="root",
  7. PROPERTIES("maximumPoolSize"=10)
  8. );
  • Register storage unit and set connection pool parameters using URL patterns
  1. REGISTER STORAGE UNIT ds_0 (
  2. URL="jdbc:mysql://127.0.0.1:3306/db_2?serverTimezone=UTC&useSSL=false",
  3. USER="root",
  4. PASSWORD="root",
  5. PROPERTIES("maximumPoolSize"=10,"idleTimeout"="30000")
  6. );
  • Register storage unit with ifNotExists clause
  1. REGISTER STORAGE UNIT IF NOT EXISTS ds_0 (
  2. HOST="127.0.0.1",
  3. PORT=3306,
  4. DB="db_0",
  5. USER="root",
  6. PASSWORD="root"
  7. );

Reserved word

REGISTER, STORAGE, UNIT, HOST, PORT, DB, USER, PASSWORD, PROPERTIES, URL