メインコンテンツまでスキップ

データベースが存在する

指定された名前のデータベースが存在するかどうかを確認します。

構文

databaseExists(dbName: str)

パラメーター

パラメーター

Type

説明

dbName

str

存在を確認するデータベースの名前。カタログ名で修飾できます。

戻り値

bool

データベースが存在するかどうかを示します。

Python
# 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")
このページの見出し