DROP
Example
Section titled “Example”DROP DATABASE testDB;Output
Section titled “Output”Query OK, 0 rows affected (0.03 sec)Explanation
Section titled “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
Section titled “Example”DROP TABLE IF EXISTS example_table;Output
Section titled “Output”DROP TABLEExplanation
Section titled “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
Section titled “Example”CREATE DATABASE TestDB;DROP DATABASE TestDB;Output
Section titled “Output”Command(s) completed successfully.Explanation
Section titled “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
Section titled “Example”DROP TABLE employees;Output
Section titled “Output”Table EMPLOYEES dropped.Explanation
Section titled “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
Section titled “Example”CREATE TABLE temp_table( id INTEGER PRIMARY KEY, name TEXT);
INSERT INTO temp_table(id, name)VALUES (1, 'Example Name');
DROP TABLE temp_table;Output
Section titled “Output”Query OK, 0 rows affected (0.00 sec)
Explanation
Section titled “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.