This topic describes how to change the default schema to another in DRDS by executing the USE command.

Background information

DRDS allows you to access different databases in the same DRDS instance, just like querying multiple databases in a standalone ApsaraDB RDS for MySQL instance. You must specify a value for DB_NAME when logging on to a DRDS instance. If you need to execute SQL statements to dynamically switch the default database to another database, you can execute the USE statement. This allows you to manage multiple databases.

Precautions

  • You must authorize the database in advance. For more information, see account and permission system.
  • After the default database is changed, the HINT syntax and SEQUENCE syntax in the original SQL statement are also directed to the new database by default, no matter whether a schema is specified.

Syntax

USE db_name   

Examples

You can use the following syntax to switch the current default database to NEW_DB.

USE NEW_DB