USE SCHEMA¶

Specifies the active/current schema for the session:

  • If a database is not specified for a session, any objects referenced in queries and other SQL statements executed in the session must be fully qualified with the database and schema, also known as the namespace, for the object (in the form of db_name.schema_name.object_name). For more information about fully-qualified object names, see Object name resolution.

  • If a database is specified for a session but the schema is not specified for a session, any objects referenced in queries and other SQL statements executed in the session must be qualified with the schema for the object (in the form of schema_name.object_name).

  • If the database and schema are specified for a user session, unqualified object names are allowed in SQL statements and queries.

See also:

CREATE SCHEMA , ALTER SCHEMA , DROP SCHEMA , SHOW SCHEMAS

Syntax¶

USE [ SCHEMA ] [<db_name>.]<name>
Copy

Parameters¶

[db_name.]name

Specifies the identifier for the schema to use for the session. If the identifier contains spaces or special characters, the entire string must be enclosed in double quotes. Identifiers enclosed in double quotes are also case-sensitive.

The SCHEMA keyword is optional if the schema name is fully qualified (in the form of db_name.schema_name).

The database name (db_name) is optional if the database is specified in the user session and the SCHEMA keyword is included.

Examples¶

Use the myschema schema with the database specified in the user session:

USE SCHEMA myschema;
Copy

Use the myschema schema in the mydb database:

USE mydb.myschema;
Copy