List views in MariaDB database with their scripts

The query below lists all views in all databases (schemas) with their definition.

Query

select vw.table_schema as database_name,
    vw.table_name as view_name,
    vw.view_definition as definition,
    tb.table_comment as description
from information_schema.views as vw
    inner join information_schema.tables as tb
        on vw.table_name = tb.table_name
-- where vw.table_schema = 'your database name'
order by database_name, view_name;

Note: if you need the information for a specific database (schema), then uncomment the table_schema line and provide your database name.

Columns

  • schema_name - database (schema) name of the view
  • view_name - name of the view
  • definition - definition script of the view
  • description - description of the view

Rows

  • One row: represents one view
  • Scope of rows: all views in all databases (schemas)
  • Ordered by: database (schema) name, view name

Sample results