SQL

Remove Items From SQL Databases Using the DROP Statement

In SQL, the DROP Statement is used to remove databases, tables, and indexes. The syntax to remove a table is:

DROP TABLE nameoftable

Wow. That’s really, really easy. I mean, you can delete craploads of data that way! It can’t be! You can also delete a database. To do so, use the DROP statement again, but this time, instead of dropping a table, let’s remove the database:

DROP DATABASE nameofdatabase

Aaaaaand, you can drop an index, which on MySQL is done using an ALTER statement, followed by TABLE, then the table name that has an index needing to drop:

ALTER TABLE nameoftable DROP INDEX nameofindex

You can also delete the data inside the table, rather than the table. This leaves the schema in tact so that you can start writing data to the database again:

TRUNCATE TABLE nameoftable

And viola, you’re deleting data like a fool!

exploits_of_a_mom