mariadb-create-view

Generates and reviews MariaDB CREATE VIEW, ALTER VIEW, and DROP VIEW statements.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Generated SQL for MariaDB views often fails or misbehaves because standard SQL assumptions do not match MariaDB's actual semantics — mutually exclusive OR REPLACE and IF NOT EXISTS clauses, the SQL SECURITY DEFINER default, updatability restrictions, and frozen-at-creation column definitions. This Skill encodes those deltas so view DDL is correct on the first attempt. ## Core Features & Use Cases - Correct view DDL generation: Produces CREATE VIEW statements with valid clause ordering, proper ALGORITHM selection (MERGE vs TEMPTABLE), and explicit SQL SECURITY settings. - Updatability and CHECK OPTION guidance: Determines whether a view is updatable or insertable and applies WITH CASCADED or LOCAL CHECK OPTION correctly for layered views. - ALTER VIEW and DROP VIEW handling: Covers atomic redefinition via CREATE OR REPLACE or ALTER VIEW, and notes that RESTRICT/CASCADE in DROP VIEW are parsed but ignored. - Use Case: When asked to create a view that filters active users and rejects out-of-scope writes, the Skill produces a MERGE-algorithm view with WITH CHECK OPTION and SQL SECURITY INVOKER instead of silently defaulting to DEFINER privileges. ## Quick Start Write a MariaDB CREATE VIEW statement for an updatable view over the users table that only exposes active rows and rejects inserts that violate that filter.

Frequently Asked Questions about mariadb-create-view

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

FAQPage Schema
How do I create or replace a view in MariaDB?▼

Use CREATE OR REPLACE VIEW view_name AS select_statement to atomically redefine a view without a window where it is missing. OR REPLACE and IF NOT EXISTS are mutually exclusive and combining them raises ER_WRONG_USAGE.

What makes a view updatable in MariaDB?▼

A view is updatable only if its SELECT avoids aggregates, DISTINCT, GROUP BY, HAVING, UNION, select-list subqueries, and outer joins, and it must use the MERGE algorithm. TEMPTABLE views are never updatable, and inserts require plain base-table columns covering all NOT NULL columns.

Does MariaDB default to SQL SECURITY DEFINER for views?▼

Yes, MariaDB views default to SQL SECURITY DEFINER, meaning the view executes with the definer's privileges rather than the caller's. Write SQL SECURITY INVOKER explicitly when you need caller-privilege semantics.

Why does SELECT * in a MariaDB view not show new columns?▼

View definitions are frozen at creation time, so SELECT * is expanded to the columns that existed when the view was created. Columns added to the base table later do not appear until you recreate the view.

What is the difference between CASCADED and LOCAL CHECK OPTION?▼

CASCADED, the default for bare WITH CHECK OPTION, validates writes against this view and all underlying views' predicates. LOCAL checks only the predicate of the view being written through, which matters for views layered on other views.

Can I create a temporary or indexed view in MariaDB?▼

No, MariaDB does not support CREATE TEMPORARY VIEW or indexes on views, and a view's SELECT cannot contain a derived table in its FROM clause. Index the underlying base table instead to improve view query performance.