USE
Description
USE specifies the current schema so that the database uses the specified schema as the default (current) schema.
Precautions
To use USE to specify a schema, you must have the USAGE permission on the schema. You can run the SHOW databases; command to view the schemas on which you have the USAGE permission. If you do not have the USAGE permission on a schema and perform operations on the schema, the current schema is set to null and no error message is displayed. You can call the database function to check whether the specified schema takes effect.
m_db=> USE test; SET m_db=> SELECT database(); ERROR: function returned NULL CONTEXT: referenced column: database
Syntax
USE schema_name
Parameters
schema_name
Specifies the name of the schema to be specified.
Value range: an existing schema name.
Examples
m_db=# SELECT database();
database
----------
public
(1 row)
m_db=# SHOW DATABASES;
Database
--------------------
information_schema
blockchain
db4ai
dbe_perf
dbe_pldebugger
dbe_pldeveloper
dbe_sql_util
m_schema
pg_catalog
pg_toast
pkg_service
public
snapshot
sqladvisor
sys
(16 rows)
m_db=# USE m_schema;
SET
m_db=# SELECT database();
database
----------
m_schema
(1 row)
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot