pyspark.sql.Catalog.dropDatabase#

Catalog.dropDatabase(dbName, ifExists=False, cascade=False)[source]#

Drops a namespace.

New in version 4.2.0.

Parameters
dbNamestr

Name of the namespace to drop. May be qualified with catalog name.

ifExistsbool, optional

If True, do not fail when the namespace does not exist.

cascadebool, optional

If True, also drop tables and functions in the namespace.

Examples

>>> spark.catalog.dropDatabase("db_drop_doc", ifExists=True, cascade=True)
>>> spark.catalog.createDatabase("db_drop_doc")
>>> spark.catalog.dropDatabase("db_drop_doc", cascade=True)
>>> spark.catalog.databaseExists("db_drop_doc")
False