Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

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!

This post first appeared on | Tiny Deathstars Of Foulness, please read the originial post: here

Share the post

Remove Items From SQL Databases Using the DROP Statement


Subscribe to | Tiny Deathstars Of Foulness

Get updates delivered right to your inbox!

Thank you for your subscription