Description
This statement is used to switch the schema in the current database, so that users can more easily operate and manage data tables under different schemas.
Syntax
Parameter Description
SCHEMA
: This is an optional keyword, you can use or omit it.schema_name
: Specifies the name of the schema to switch to.
Usage Example
- Switch to the schema named
ods_schema
: - Switch to the schema named
reporting_schema
, omitting theSCHEMA
keyword: - Switch to the schema named
customer_data
and perform some query operations after switching:
Precautions
- When you use the
USE
statement in an SQL query to switch to a certain schema, the subsequent query operations will default to the data tables under that schema. - If you need to frequently switch between multiple schemas, you can use the
USE
statement multiple times in the SQL query. - When using the
USE
statement, please ensure that the specified schema name exists in the current database, otherwise it will cause an error.