mariadb-drop-table

Documents MariaDB-specific DROP TABLE syntax, behaviors, and pitfalls for writing correct statements.

28|115|Updated Jan 28, 2025
One-click install
npx skills add https://github.com/mariadb-corporation/mariadb-docs --skill mariadb-drop-table-mariadb-corporation
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: mariadb-drop-table
Source: https://github.com/mariadb-corporation/mariadb-docs/tree/main/agent-skills/granular/statements/mariadb-drop-table
Command: npx skills add https://github.com/mariadb-corporation/mariadb-docs --skill mariadb-drop-table-mariadb-corporation

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Generated SQL often assumes standard DROP TABLE semantics, but MariaDB diverges in ways that cause errors or data loss: RESTRICT/CASCADE are no-ops, multi-table drops are partial, DDL implicitly commits, and DROP TABLE fails on views or FK-referenced tables. This Skill captures those deltas so DROP TABLE statements targeting MariaDB are correct the first time. ## Core Features & Use Cases - MariaDB behavior deltas: Covers RESTRICT/CASCADE being parsed but inert, partial drops in multi-table statements, IF EXISTS note-level warnings, and automatic trigger removal. - Safety guards: Documents DROP TEMPORARY TABLE to avoid dropping a same-named base table, foreign-key blocking (ER_ROW_IS_REFERENCED) with the foreign_key_checks workaround, and WAIT/NOWAIT lock-wait bounds. - Correct alternatives: Points to DROP VIEW for views, CREATE OR REPLACE TABLE for atomic replacement, and TRUNCATE TABLE vs DELETE FROM for emptying a table. - Use Case: When asked to write a migration script that drops and recreates a table in MariaDB 11.8, produce CREATE OR REPLACE TABLE instead of a non-atomic DROP plus CREATE pair. ## Quick Start Ask the AI to write or review a MariaDB DROP TABLE statement, for example dropping several tables safely while tolerating missing ones and bounding the metadata-lock wait.

Frequently Asked Questions about mariadb-drop-table

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I drop a table in MariaDB without errors if it doesn't exist?▼

Use DROP TABLE IF EXISTS tbl_name. In MariaDB, IF EXISTS converts the unknown-table error into a note-level warning visible via SHOW WARNINGS, so the statement succeeds even when the table is missing.

Does DROP TABLE CASCADE remove dependent objects in MariaDB?▼

No. In MariaDB, RESTRICT and CASCADE on DROP TABLE are parsed but do nothing; they exist only for portability. To remove a referencing foreign key, you must drop or alter the referencing table explicitly.

Why does DROP TABLE fail with ER_ROW_IS_REFERENCED in MariaDB?▼

The drop is blocked because another table's foreign key references the target table. Drop the referencing foreign key first, or set foreign_key_checks = 0 for the session to bypass the check.

Can DROP TABLE be rolled back in a MariaDB transaction?▼

No. DROP TABLE performs an implicit commit and cannot be rolled back. The single exception is DROP TEMPORARY TABLE, which does not implicitly commit the surrounding transaction.

How do I safely drop a temporary table in MariaDB?▼

Use DROP TEMPORARY TABLE tbl_name. The TEMPORARY keyword restricts the drop to temporary tables, so a base table with the same name can never be dropped by accident.

What happens when one table is missing in a multi-table DROP TABLE?▼

MariaDB performs a partial drop: existing tables are still dropped and the missing ones are reported together at the end. Without IF EXISTS you get both the drops and an error, since the statement is not all-or-nothing.