How can you implement Inline view in MariaDB?


An inline view in MariaDB is implemented as a subquery in the FROM clause that acts as a virtual table. The key requirement is that every inline view must have an alias.

Basic Syntax

Key Features

Mandatory Alias

Unlike Oracle, MariaDB requires explicit aliases for inline views. For example:

Algorithm Options

MariaDB supports three view algorithms:

  • MERGE: Combines view definition with the main query
  • TEMPTABLE: Stores results in a temporary table
  • UNDEFINED: Lets MariaDB choose the optimal algorithm

Limitations

MERGE Algorithm Restrictions

Inline views cannot use MERGE if they contain:

  • HAVING clauses
  • GROUP BY statements
  • DISTINCT operations
  • Aggregate functions (MAX, MIN, SUM, COUNT)
  • Subqueries in the SELECT list
  • UNION operations

View Updates

For an inline view to be updatable, it must:

  • Contain all base table columns without default values
  • Have simple columns without derived calculations
  • Not contain multiple references to base table columns

 

 

 

About MinervaDB Corporation 47 Articles
A boutique private-label enterprise-class MySQL, MariaDB, MyRocks, PostgreSQL and ClickHouse consulting, 24*7 consultative support and remote DBA services company with core expertise in performance, scalability and high availability. Our consultants have several years of experience in architecting and building web-scale database infrastructure operations for internet properties from diversified verticals like CDN, Mobile Advertising Networks, E-Commerce, Social Media Applications, SaaS, Gaming and Digital Payment Solutions. Our globally distributed team working on multiple timezones guarantee 24*7 Consulting, Support and Remote DBA Services delivery for MySQL, MariaDB, MyRocks, PostgreSQL and ClickHouse.