使用資料庫

說明

USE 陳述式用於設定目前的資料庫。設定目前的資料庫後,SQL 參考的非限定資料庫成品,例如表格、函數和檢視,將從目前的資料庫解析。預設資料庫名稱為「default」。

語法

USE database_name

參數

範例

-- 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)