USE Database

Description

USE statement is used to set the current database. After the current database is set, the unqualified database artifacts such as tables, functions and views that are referenced by SQLs are resolved from the current database. The default database name is ‘default’.

Syntax

USE database_name

Parameter

Examples

-- Use the 'userdb' which exists.
USE userdb;

-- Use the 'userdb1' which doesn't exist
USE userdb1;
Error: org.apache.spark.sql.catalyst.analysis.NoSuchDatabaseException: Database 'userdb1' not found;
(state=,code=0)