USE SCHEMA¶

Specifies the active/current schema for the session.

If a database and schema, also known as a namespace, are not specified for a user session, all objects reference in SQL statements or queries executed in the system must be fully-qualified (in the form of db_name.schema_name.object_name). Specifying a database and schema for a user session enables using unqualified object names in SQL statements and queries.

For more information about fully-qualified object names, see Object Name Resolution.

See also:

CREATE SCHEMA , ALTER SCHEMA , DROP SCHEMA , SHOW SCHEMAS

Syntax¶

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

Parameters¶

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.

If name is not fully-qualified (with db_name), the command looks for the schema in the current database for the session.

Usage Notes¶

  • The SCHEMA keyword is optional if a database has been specified for the session or the schema name is fully-qualified.

Examples¶

Use the myschema schema in the current database:

USE myschema;
Copy

Use the otherschema schema in the otherdb database:

USE otherdb.otherschema;
Copy