OceanBase logo

OceanBase

A unified distributed database ready for your transactional, analytical, and AI workloads.

Product Overview
DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Resources

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS

OceanBase Cloud

OceanBase Database

Tools

Connectors and Middleware

QUICK START

OceanBase Cloud

OceanBase Database

BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Company

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

International - English
中国站 - 简体中文
日本 - 日本語
Sign In
Start on Cloud

OceanBase

A unified distributed database ready for your transactional, analytical, and AI workloads.

Product Overview
DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS
OceanBase CloudOceanBase Database
ToolsConnectors and Middleware
QUICK START
OceanBase CloudOceanBase Database
BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

Start on Cloud
编组
All Products
    • Databases
    • iconOceanBase Database
    • iconOceanBase Cloud
    • iconOceanBase Tugraph
    • iconInteractive Tutorials
    • iconOceanBase Best Practices
    • Tools
    • iconOceanBase Cloud Platform
    • iconOceanBase Migration Service
    • iconOceanBase Developer Center
    • iconOceanBase Migration Assessment
    • iconOceanBase Admin Tool
    • iconOceanBase Loader and Dumper
    • iconOceanBase Deployer
    • iconKubernetes operator for OceanBase
    • iconOceanBase Diagnostic Tool
    • iconOceanBase Binlog Service
    • Connectors and Middleware
    • iconOceanBase Database Proxy
    • iconEmbedded SQL in C for OceanBase
    • iconOceanBase Call Interface
    • iconOceanBase Connector/C
    • iconOceanBase Connector/J
    • iconOceanBase Connector/ODBC
    • iconOceanBase Connector/NET
icon

OceanBase Database

SQL - V4.3.3

    Download PDF

    OceanBase logo

    The Unified Distributed Database for the AI Era.

    Follow Us
    Products
    OceanBase CloudOceanBase EnterpriseOceanBase Community EditionOceanBase seekdb
    Resources
    DocsBlogWhite PaperLive DemosTraining & CertificationTicket
    Company
    About OceanBaseTrust CenterLegalPartnerContact Us
    Follow Us

    © OceanBase 2026. All rights reserved

    Cloud Service AgreementPrivacy PolicySecurity
    Contact Us
    Document Feedback
    1. Documentation Center
    2. OceanBase Database
    3. SQL
    4. V4.3.3
    iconOceanBase Database
    SQL - V 4.3.3
    Databases
    • OceanBase Database
    • OceanBase Cloud
    • OceanBase Tugraph
    • Interactive Tutorials
    • OceanBase Best Practices
    Tools
    • OceanBase Cloud Platform
    • OceanBase Migration Service
    • OceanBase Developer Center
    • OceanBase Migration Assessment
    • OceanBase Admin Tool
    • OceanBase Loader and Dumper
    • OceanBase Deployer
    • Kubernetes operator for OceanBase
    • OceanBase Diagnostic Tool
    • OceanBase Binlog Service
    Connectors and Middleware
    • OceanBase Database Proxy
    • Embedded SQL in C for OceanBase
    • OceanBase Call Interface
    • OceanBase Connector/C
    • OceanBase Connector/J
    • OceanBase Connector/ODBC
    • OceanBase Connector/NET
    SQL
    KV
    • V 4.6.0
    • V 4.4.2
    • V 4.3.5
    • V 4.3.3
    • V 4.3.1
    • V 4.3.0
    • V 4.2.5
    • V 4.2.2
    • V 4.2.1
    • V 4.2.0
    • V 4.1.0
    • V 4.0.0
    • V 3.1.4 and earlier

    Query materialized views

    Last Updated:2024-12-02 03:48:29  Updated
    Share
    What is on this page
    View the definition of a materialized view
    View the information about materialized views by using system views

    folded

    Share

    This topic describes how to query materialized views.

    View the definition of a materialized view

    You can use the SHOW CREATE TABLE statement to query the definition of a materialized view.

    Here is an example:

    Query the definition of a materialized view named mv_tbl1.

    obclient [SYS]> SHOW CREATE TABLE mv_tbl1;
    

    The return result is as follows:

    +---------+---------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+----------------------+
    | VIEW    | CREATE VIEW                                                                                                                                             | CHARACTER_SET_CLIENT | COLLATION_CONNECTION |
    +---------+---------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+----------------------+
    | MV_TBL1 | CREATE MATERIALIZED VIEW "MV_TBL1" AS select "SYS"."TBL1"."ID" AS "ID","SYS"."TBL1"."NAME" AS "NAME" from "SYS"."TBL1" where ("SYS"."TBL1"."AGE" >= 20) | utf8mb4              | utf8mb4_bin          |
    +---------+---------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------+----------------------+
    1 row in set
    

    View the information about materialized views by using system views

    The following table describes system views that you can query to view the information about materialized views.

    View name
    Description
    ALL_MVIEWS Displays the information about materialized views.
    DBA_MVREF_STATS_SYS_DEFAULTS Displays all default values of the refresh history statistics properties for materialized views in the entire system.
    DBA_MVREF_STATS_PARAMS Displays the refresh statistics properties associated with each materialized view.
    DBA_MVREF_RUN_STATS Displays the information about each refresh of the materialized views. Each refresh is identified by a REFRESH_ID.
    DBA_MVREF_STATS Displays the basic timing statistics of materialized view refreshes.
    DBA_MVREF_CHANGE_STATS Displays refresh statistics of materialized views.
    DBA_MVREF_STMT_STATS Displays the information about the refresh statements of materialized views.

    Here is an example:

    SELECT owner, mview_name, container_name, query, query_len FROM sys.DBA_MVIEWS;
    

    The return result is as follows:

    +---------+--------------+-----------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------+
    | OWNER   | MVIEW_NAME   | CONTAINER_NAME        | QUERY                                                                                                                                                                                             | QUERY_LEN |
    +---------+--------------+-----------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------+
    | SYS     | MV_TBL1_TBL2 | __mv_container_500214 | select "T1"."ID" AS "ID","T1"."NAME" AS "NAME","T2"."NOTES" AS "NOTES" from "SYS"."TBL1" "T1","SYS"."TBL2" "T2" where ("T1"."ID" = "T2"."TBL1_ID")                                                |       146 |
    | SYS     | MV3_TBL1     | __mv_container_500211 | select "SYS"."TBL1"."ID" AS "ID","SYS"."TBL1"."NAME" AS "NAME" from "SYS"."TBL1" where ("SYS"."TBL1"."AGE" >= 20)                                                                                 |       113 |
    | SYS     | MV2_TBL1     | __mv_container_500208 | select "SYS"."TBL1"."ID" AS "ID","SYS"."TBL1"."NAME" AS "NAME" from "SYS"."TBL1" where ("SYS"."TBL1"."AGE" >= 20)                                                                                 |       113 |
    | SYS     | MV1_TBL1     | __mv_container_500205 | select "SYS"."TBL1"."ID" AS "ID","SYS"."TBL1"."NAME" AS "NAME" from "SYS"."TBL1" where ("SYS"."TBL1"."AGE" >= 20)                                                                                 |       113 |
    | SYS     | MV_TBL3      | __mv_container_500202 | select "SYS"."TBL3"."COL2" AS "COL2",count(*) AS "CNT",count("SYS"."TBL3"."COL3") AS "CNT_COL3",sum("SYS"."TBL3"."COL3") AS "SUM_COL3" from "SYS"."TBL3" group by "SYS"."TBL3"."COL2"             |       181 |
    | SYS     | MV_TBL1      | __mv_container_500179 | select "SYS"."TBL1"."ID" AS "ID","SYS"."TBL1"."NAME" AS "NAME" from "SYS"."TBL1" where ("SYS"."TBL1"."AGE" >= 20)                                                                                 |       113 |
    | USER001 | MV_TEST_TBL1 | __mv_container_500154 | select "USER001"."TEST_TBL1"."COL1" AS "COL1","USER001"."TEST_TBL1"."COL2" AS "COL2","USER001"."TEST_TBL1"."COL3" AS "COL3" from "USER001"."TEST_TBL1" where ("USER001"."TEST_TBL1"."COL3" >= 30) |       193 |
    +---------+--------------+-----------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------+
    7 rows in set
    

    Previous topic

    Create a materialized view
    Last

    Next topic

    Drop a materialized view
    Next
    What is on this page
    View the definition of a materialized view
    View the information about materialized views by using system views