The query below lists all views in all databases (schemas) with their definition.
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 tb.table_name = vw.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.
- 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
- One row: represents one view
- Scope of rows: all views in all databases (schemas)
- Ordered by: database (schema) name, view name