지정한 이름의 데이터베이스가 있는지 확인합니다.
문법
databaseExists(dbName: str)
매개 변수
| 매개 변수 | 유형 | 설명 |
|---|---|---|
dbName |
str | 존재 여부를 확인할 데이터베이스의 이름입니다. 카탈로그 이름으로 정규화할 수 있습니다. |
Returns
bool
데이터베이스가 있는지 여부를 나타냅니다.
예제
# 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")