Dropping a database schema
In this recipe, you will learn how to drop a database in Hive.
Getting ready
Drop Database statements drop the database and the objects inside that database. When a database is dropped, its directory is also deleted. The general format of dropping a database is as follows:
DROP (DATABASE|SCHEMA) [IF EXISTS] database_name [RESTRICT|CASCADE];
Where:
DATABASE|SCHEMA: These are the same thing. These words can be used interchangeably.[IF EXISTS]: This is an optional clause. If not used, an error is thrown when there is an attempt to drop a database that does not exist.[RESTRICT|CASCADE]: This is an optional clause.RESTRICTis used to restrict the database from getting dropped if there are one or more tables present in the database.RESTRICTis the default behavior of the database.CASCADEis used to drop all the tables present in the database before dropping the database.
How to do it…
Follow these steps to drop a database in Hive:
- The following statement drops the...