Note
This statement is supported starting from V4.3.5 BP2.
Description
This statement is used to switch the catalog of the current session. After a successful switch, the current session can access objects in the target catalog directly in the form of schema_name.object_name, without using the catalog prefix.
The default catalog for each session is INTERNAL. You can use the CURRENT_CATALOG() or CATALOG() function to view the catalog of the current session.
Limitations and considerations
- Catalog names are case-insensitive. Catalog names that are not enclosed in double quotation marks are uniformly converted to uppercase before matching.
- If the target catalog does not exist, or the current user does not have the
USE CATALOGobject privilege on the target catalog, an error will be returned with error code-11080or-11083.
Privilege requirements
To switch to a specified external catalog, the current user must have the USE CATALOG object privilege on that catalog. For more information about OceanBase Database privileges, see Privilege types in Oracle-compatible mode.
Syntax
SET CATALOG catalog_name
Parameters
Parameter |
Description |
|---|---|
| catalog_name | Indicates the name of the target catalog, which can beINTERNALor the name of an existing external catalog. The names are case-insensitive and are converted to uppercase before matching if not enclosed in double quotes. |
Examples
Switch to the system internal catalog
INTERNAL.obclient> SET CATALOG internal;Create an external catalog, switch to it, confirm the current catalog using the
CURRENT_CATALOG()function, and then drop the catalog.obclient> CREATE EXTERNAL CATALOG tmp_catalog PROPERTIES = (TYPE = 'JDBC', URL = 'jdbc:sqlserver://10.10.10.1:1433'); obclient> SET CATALOG tmp_catalog; obclient> SELECT CURRENT_CATALOG() FROM dual;The query result is as follows:
+-------------------+ | CURRENT_CATALOG() | +-------------------+ | TMP_CATALOG | +-------------------+ 1 row in setobclient> SET CATALOG internal; obclient> DROP CATALOG tmp_catalog;