Hive - Drop Database
Hive - Drop Database
This chapter describes how to drop a database in Hive. The usage of SCHEMA and DATABASE are
same.
The following queries are used to drop a database. Let us assume that the database name is userdb.
The following query drops the database using CASCADE. It means dropping respective tables before
dropping the database.
JDBC Program
import java.sql.SQLException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.sql.DriverManager;
// get connection
Connection con = DriverManager.getConnection("jdbc:hive://localhost:1
Statement stmt = con.createStatement();
stmt.executeQuery("DROP DATABASE userdb");
con.close();
}
}
Save the program in a file named HiveDropDb.java. Given below are the commands to compile and
execute this program.
$ javac HiveDropDb.java
$ java HiveDropDb
Output: