DROP
DROP in SQL is a statement used to delete the entire structure or scheme of a database object. It is predominantly employed to remove tables, databases, or other relational database management system objects from the database. Once the object is dropped, it cannot be recovered.
Example
Output
Explanation
The DROP DATABASE statement is used to delete a database in SQL. In the provided example, the database named “testDB” is deleted. The output indicates that the query was successful and no rows were affected as it was a database-level operation, not a table-level operation.
Example
Output
Explanation
The SQL statement above deletes the table named ‘example_table’ if it exists in the database. If the table does not exist, nothing happens and no error message is produced due to the IF EXISTS
clause. The output DROP TABLE
indicates the operation was successful.
Example
Output
Explanation
In the example, a database named “TestDB” is first created and then dropped, which means it’s deleted. ‘Command(s) completed successfully.’ message indicating that the operation has been completed successfully.
Example
Output
Explanation
The DROP TABLE statement is used to delete a table in Oracle. The statement deletes the entire table structure and associated data. The specific command “DROP TABLE employees;” will delete the table employees
from the database. If the table is successfully deleted, Oracle will output “Table EMPLOYEES dropped.”.
Example
Output
Query OK, 0 rows affected (0.00 sec)
Explanation
In the above example, a temporary table, temp_table
, is first created and populated with a dummy row of data. The DROP TABLE
statement is then used to remove this table from the database entirely. As no rows are directly affected by the table deletion, the output of the DROP TABLE
operation is 0 rows affected.