Syntax\n------\n\nDROP [TEMPORARY] TABLE [IF EXISTS] [/COMMENT TO SAVE/]\n    tbl_name [, tbl_name] ...\n    [WAIT n|NOWAIT]\n    [RESTRICT | CASCADE]\n\nDescription\n-----------\n\nDROP TABLE removes one or more tables. You must have the DROP privilege for each table. All table data and the table definition are removed, as well as triggers associated to the table, so be careful with this statement! If any of the tables named in the argument list do not exist, MariaDB returns an error indicating by name which non-existing tables it was unable to drop, but it also drops all of the tables in the list that do exist.\n\nImportant: When a table is dropped, user privileges on the table are not automatically dropped. See GRANT.\n\nIf another thread is using the table in an explicit transaction or an autocommit transaction, then the thread acquires a metadata lock (MDL) on the table. The DROP TABLE statement will wait in the "Waiting for table metadata lock" thread state until the MDL is released. MDLs are released in the following cases:\n\n If an MDL is acquired in an explicit transaction, then the MDL will be released when the transaction ends.\n If an MDL is acquired in an autocommit transaction, then the MDL will be released when the statement ends.\n Transactional and non-transactional tables are handled the same.\n\nNote that for a partitioned table, DROP TABLE permanently removes the table definition, all of its partitions, and all of the data which was stored in those partitions. It also removes the partitioning definition (.par) file associated with the dropped table.\n\nFor each referenced table, DROP TABLE drops a temporary table with that name, if it exists. If it does not exist, and the TEMPORARY keyword is not used, it drops a non-temporary table with the same name, if it exists. The TEMPORARY keyword ensures that a non-temporary table will not accidentally be dropped.\n\nUse IF EXISTS to prevent an error from occurring for tables that do not\\\nexist. A NOTE is generated for each non-existent table when usingIF EXISTS. See SHOW WARNINGS.\n\nIf a foreign key references this table, the table cannot be dropped. In this case, it is necessary to drop the foreign key first.\n\nRESTRICT and CASCADE are allowed to make porting from other database systems easier. In MariaDB, they do nothing.\n\nThe comment before the table names (/COMMENT TO SAVE/) is stored in the binary log. That feature can be used by replication tools to send their internal messages.\n\nIt is possible to specify table names as db_name.tab_name. This is useful to delete tables from multiple databases with one statement. See Identifier Qualifiers for details.\n\nThe DROP privilege is required to use DROP TABLE on non-temporary tables. For temporary tables, no privilege is required, because such tables are only visible for the current session.\n\nNote: DROP TABLE automatically commits the current active transaction, unless you use the TEMPORARY keyword.\n\nDROP TABLE reliably deletes table remnants inside a storage engine even if the .frm file is missing.\n\nDROP TABLE does not reliably delete table remnants inside a storage engine even if the .frm file is missing. A missing .frm file will result in the statement failing.\n\nWAIT/NOWAIT\n\nSet the lock wait timeout. See WAIT and NOWAIT.\n\nDROP TABLE in replication\n\nDROP TABLE has the following characteristics in replication:\n\n DROP TABLE IF EXISTS are always logged.\n DROP TABLE without IF EXISTS for tables that don't exist are not written to the binary log.\n Dropping of TEMPORARY tables are prefixed in the log with TEMPORARY. These drops are only logged when running statement or mixed mode replication.\n One DROP TABLE statement can be logged with up to 3 different DROP statements:\n   DROP TEMPORARY TABLE list_of_non_transactional_temporary_tables\n   DROP TEMPORARY TABLE list_of_transactional_temporary_tables\n   DROP TABLE list_of_normal_tables\n\nDROP TABLE on the master is treated on the slave as DROP TABLE IF EXISTS. You can change that by setting slave-ddl-exec-mode to STRICT.\n\nDropping an Internal #sql-... Table\n\nDROP TABLE is atomic.\n\nif the mariadbd process is killed during an ALTER TABLE, you may find a table named #sql-... in your data directory. These temporary tables will always be deleted automatically.\n\nIf you want to delete one of these tables explicitly you can do so by using the following syntax:\n\n``\nDROP TABLE #mysql50##sql-...;\n`\n\nWhen running an ALTER TABLE…ALGORITHM=INPLACE that rebuilds the table, InnoDB will create an internal #sql-ib table.\n\nThe same name as the .frm file is used for the intermediate copy of the table. The #sql-ib names are used by TRUNCATE and delayed DROP.\n\nThe #sql-ib tables will be deleted automatically.\n\nDropping All Tables in a Database\n\nThe best way to drop all tables in a database is by executing DROP DATABASE, which will drop the database itself, and all tables in it.\n\nHowever, if you want to drop all tables in the database, but you also want to keep the database itself and any other non-table objects in it, then you would need to execute DROP TABLE to drop each individual table. You can construct these DROP TABLE commands by querying the TABLES table in the information_schema database. For example:\n\n`\nSELECT CONCAT('DROP TABLE IF EXISTS ', TABLE_SCHEMA, '.', TABLE_NAME, ';')\nFROM information_schema.TABLES\nWHERE TABLE_SCHEMA = 'mydb';\n`\n\nAtomic DROP TABLE\n\nMariaDB starting with 10.6.1\n\nDROP TABLE for a single table is atomic (MDEV-25180) for most engines, including InnoDB, MyRocks, MyISAM and Aria. This means that if there is a crash (server down or power outage) during DROP TABLE, all tables that have been processed so far will be completely dropped, including related trigger files and status entries, and the binary log will include a DROP TABLE statement for the dropped tables. Tables for which the drop had not started will be left intact.DROP TABLE was extended to be able to delete a table that was only partly dropped (MDEV-11412), as explained above. Atomic DROP TABLE is the final piece to make DROP TABLE fully reliable. Dropping multiple tables is crash-safe. See Atomic DDL for more information.\n\nThere is a small chance that, during a server crash happening in the middle of DROP TABLE, some storage engines that were using multiple storage files, like MyISAM, could have only a part of its internal files dropped. In MariaDB 10.5, DROP TABLE was extended to be able to delete a table that was only partly dropped (MDEV-11412) as explained above. Atomic DROP TABLE is the final piece to make DROP TABLE` fully reliable. Dropping multiple tables is crash-safe. See Atomic DDL for more information.\n\nExamples\n--------\n\nDROP TABLE Employees, Customers;\n\nURL: https://mariadb.com/docs/server/reference/sql-statements/data-definition/drop/drop-table