SET SCHEMA
Use the SET SCHEMA command to change to a different schema. If you specify db_name.schema_name to connect to a schema in a different database, the command issues a SET CATALOG command to change to the database. You cannot use the SET SCHEMA command to change to a schema in a different database within the body of a stored procedure or inside an explicit transaction (BEGIN/COMMIT pair).
Syntax
SET SCHEMA [<database_name>.]<schema_name>
Inputs
The SET SCHEMA command takes the following inputs:
Input | Description |
---|---|
<database_name> | The name of the database that contains the schema to which you want to change. The default is the current database. |
<schema_name> | The schema to which you want to change. |
Output
The SET SCHEMA command has the following output:
Output | Description |
---|---|
SET SCHEMA | The command was successful. |
ERROR: SET SCHEMA: object <name> does not exist. | The schema does not exist. |
Privileges
You must be an administrator or you must have the List privilege for the schema. If the schema resides in a different database, you must have the List privilege to change to that database.
Usage
MYDB.SCH1(USER)=> SET SCHEMA schema1;
SET SCHEMA
MYDB.SCHEMA1(USER)=>