Lưu ý
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử đăng nhập hoặc thay đổi thư mục.
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử thay đổi thư mục.
Check if the database with the specified name exists.
Syntax
databaseExists(dbName: str)
Parameters
| Parameter | Type | Description |
|---|---|---|
dbName |
str | Name of the database to check existence. Can be qualified with catalog name. |
Returns
bool
Indicating whether the database exists.
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")