檢查該名稱的資料庫是否存在。
語法
databaseExists(dbName: str)
參數
| 參數 | 類型 | 說明 |
|---|---|---|
dbName |
str | 資料庫名稱以確認存在性。 可以用目錄名稱來限定。 |
退貨
bool
顯示資料庫是否存在。
Examples
# Check if 'test_new_database' database exists
spark.catalog.databaseExists("test_new_database")
# False
_ = spark.sql("CREATE DATABASE test_new_database")
spark.catalog.databaseExists("test_new_database")
# True
# Using the fully qualified name with the catalog name.
spark.catalog.databaseExists("spark_catalog.test_new_database")
# True
_ = spark.sql("DROP DATABASE test_new_database")