Name
DROP
Synopsis
DROP DATABASEname
DROP INDEXname
DROP TABLE [IF EXISTS]name
[,name2
, ...] DROP FUNCTIONname
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 runningmysqladmin
, 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 theDROP INDEX
statement, you must haveSELECT,
INSERT
,DELETE
,UPDATE
,CREATE
andDROP
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 haveDELETE
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.