Name

DROP

Synopsis

DROP DATABASE name
DROP INDEX name
DROP TABLE [IF EXISTS] name[, name2, ...]
DROP FUNCTION name

Permanently remove a database, table, index, or function from the MySQL system.

DROP DATABASE

Will remove an entire database with all of its associated files. The number of files deleted will be returned to the user. Because three files represent most tables, the number returned is usually the number of tables times three. This is equivalent to running the mysqladmin drop utility. As with running mysqladmin, you must be the administrative user for MySQL (usually root or mysql) to perform this statement.

DROP INDEX

Statement provides for compatibility with other SQL implementations. In older versions of MySQL, this statement does nothing. As of 3.22, this statement is equivalent to ALTER TABLE . . . DROP INDEX. To perform the DROP INDEX statement, you must have SELECT, INSERT, DELETE, UPDATE, CREATE and DROP privileges for the table in question.

DROP TABLE

Will erase an entire table permanently. In the current implementation, MySQL simply deletes the files associated with the table. As of 3.22, you may specify IF EXISTS to make MySQL not return an error if you attempt to remove a table that does not exist. You must have DELETE privileges on the table to use this statement.

DROP FUNCTION

Will remove a user defined function from the running MySQL server process. This does not actually delete the library file containing the function. You may add the function again at any time ...

Get MySQL and mSQL now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.