mariadb-create-database

Documents MariaDB-specific syntax and behavior for CREATE, ALTER, and DROP DATABASE statements.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? LLMs frequently generate standard-SQL assumptions that are wrong or dangerous on MariaDB, such as treating CREATE OR REPLACE DATABASE as a safe create-if-missing (it drops the existing database first), expecting a RENAME DATABASE statement, or using the legacy 3-byte utf8 charset instead of utf8mb4. ## Core Features & Use Cases - Syntax reference: Full CREATE / ALTER / DROP DATABASE syntax including OR REPLACE, IF NOT EXISTS, CHARACTER SET, COLLATE, and COMMENT options. - Footgun table: A "What LLMs Often Miss" section mapping common wrong assumptions to the correct MariaDB form, such as the OR REPLACE data-loss risk and the absence of RENAME DATABASE. - Version context: Defaults to MariaDB 11.8 LTS and flags newer-than-10.6 features like the utf8mb4 default-charset change since 11.6. - Use Case: When asked to write a migration script that recreates a database, the agent correctly chooses CREATE OR REPLACE DATABASE for a full reset versus CREATE DATABASE IF NOT EXISTS for create-if-absent, avoiding accidental data loss. ## Quick Start Ask the agent to write a MariaDB CREATE DATABASE statement for a new application schema with utf8mb4 charset and a comment.

Frequently Asked Questions about mariadb-create-database

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

FAQPage Schema
How do I create a database in MariaDB if it does not exist?▼

Use CREATE DATABASE IF NOT EXISTS db_name to create the database only when absent, downgrading the duplicate-name error 1007 to a note. Never combine IF NOT EXISTS with OR REPLACE, since they express opposite intents.

What is the difference between CREATE OR REPLACE DATABASE and IF NOT EXISTS in MariaDB?▼

CREATE OR REPLACE DATABASE drops the existing database first, irreversibly deleting every table, then recreates it. IF NOT EXISTS only creates the database when missing and leaves an existing one untouched.

Does MariaDB have a RENAME DATABASE statement?▼

No, MariaDB has no RENAME DATABASE or RENAME SCHEMA statement; it was removed as unsafe. Rename per-table with RENAME TABLE old_db.t TO new_db.t, or dump and reload the database.

Should I use utf8 or utf8mb4 for a MariaDB database charset?▼

Use utf8mb4 for full Unicode support; plain utf8 is the legacy 3-byte alias. On fresh MariaDB 11.6+ installs, utf8mb4 is already the default charset with default collation uca1400_ai_ci.

Does ALTER DATABASE in MariaDB change existing table charsets?▼

No, ALTER DATABASE only changes the database default CHARACTER SET, COLLATE, or COMMENT for newly created objects. Existing tables keep their charset, and existing stored routines must be dropped and recreated to pick up the new default.

Can DROP DATABASE be rolled back in MariaDB?▼

No, DDL statements like DROP DATABASE perform an implicit commit and cannot be rolled back inside a transaction. DROP DATABASE removes the database and all its tables, and privileges granted on it are not automatically removed.