CREATE VIEW
This page is part of MariaDB's Documentation.
The parent of this page is: SQL Statements for MariaDB Xpand
Topics on this page:
Overview
Creates view of the database as specified from the given SELECT
statement.
USAGE
Common Syntax:
CREATE [OR REPLACE]
[ALGORITHM = {MERGE | TEMPTABLE}]
[DEFINER = {CURRENT_USER | <user_spec>}]
[SQL SECURITY {DEFINER | INVOKER}]
VIEW [IF NOT EXISTS] <view_name>
DETAILS
MariaDB Xpand's CREATE VIEW
statement has some differences from MariaDB Enterprise Server:
The
DEFINER = user
clause is ignoredThe
SQL SECURITY { DEFINER | INVOKER }
clause is ignored
EXAMPLES
CREATE VIEW
To create a view in the currently selected database:
CREATE
VIEW 2022_01_invoices AS
SELECT * FROM invoices
WHERE MONTH(invoice_date) = 1 AND YEAR(invoice_date) = 2022;
Specify an Algorithm
To specify the algorithm used to process the view, specify the ALGORITHM
clause:
CREATE
ALGORITHM = TEMPTABLE
VIEW 2022_01_invoices AS
SELECT * FROM invoices
WHERE MONTH(invoice_date) = 1 AND YEAR(invoice_date) = 2022;
Specify the Security Context
MariaDB Xpand supports the SQL SECURITY
clause for compatibility, but the specified security context is ignored:
CREATE
SQL SECURITY DEFINER
VIEW 2022_01_invoices AS
SELECT * FROM invoices
WHERE MONTH(invoice_date) = 1 AND YEAR(invoice_date) = 2022;