The DROP TABLE explanation is utilized to eliminate a current table including every one of its triggers, limitations, consents.
Syntax
Following is the Syntax of the DROP TABLE proclamation.
ij> DROP TABLE table_name;
Example
Assume you have a table named Student in the information base. The accompanying SQL proclamation erases a table named Student.
ij> DROP TABLE Student;
0 rows inserted/updated/deleted
Since we have taken out the table on the off chance that we attempt to portray it, we will get a mistake as follows
ij> DESCRIBE Student;
IJ ERROR: No table exists with the name STUDENT
Drop Table using JDBC program
This part shows you how to drop a table in Apache Derby data set utilizing JDBC application.
On the off chance that you need to demand the Derby network worker utilizing network customer, ensure that the worker is ready for action. The class name for the Network customer driver is org.apache.derby.jdbc.ClientDriver and the URL is jdbc:derby://localhost:1527/DATABASE_NAME;create=true;user=USER_NAME;passw ord=PASSWORD"
Follow the means offered beneath to drop a table in Apache Derby
Step 1: Register the driver
To speak with the information base, most importantly, you need to enroll the driver. The forName() technique for the Class acknowledges a String esteem speaking to a class name loads it in to the memory, which consequently enrolls it. Register the driver utilizing this strategy.
Step 2: Get the connection
By and large, the initial step we do to convey to the information base is to interface with it. The Connection class speaks to the actual association with an information base worker. You can make an association object by summoning the getConnection() technique for the DriverManager class. Make an association utilizing this technique.
Step 3: Create a statement object
You need to make a Statement or PreparedStatement or, CallableStatement objects to send SQL articulations to the data set. You can make these utilizing the techniques createStatement(), prepareStatement() and, prepareCall() individually. Make both of these items utilizing the fitting strategy.
Step 4: Execute the query
Subsequent to making an assertion, you need to execute it. The Statement class gives different strategies to execute a question like the execute() technique to execute an explanation that profits more than one outcome set. The executeUpdate() technique execute inquiries like INSERT, UPDATE, DELETE. The executeQuery() strategy to results that profits information and so forth Use both of these techniques and execute the assertion made beforehand.
Example
Following JDBC model exhibits how to drop a table in Apache Derby utilizing JDBC program. Here, we are associating with an information base named sampleDB (will make on the off chance that it doesn't exist) utilizing the inserted driver.
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
public class DropTable {
public static void main(String args[]) throws Exception {
//Registering the driver
Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
//Getting the Connection object
String URL = "jdbc:derby:sampleDB;create=true";
Connection conn = DriverManager.getConnection(URL);
//Creating the Statement object
Statement stmt = conn.createStatement();
//Executing the query
String query = "DROP TABLE Employees";
stmt.execute(query);
System.out.println("Table dropped");
}
}
Output
On executing the above program, you will get the accompanying yield −
Table dropped