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.4.2

    Download PDF

    OceanBase logo

    The Unified Distributed Database for the AI Era.

    Follow Us
    Products
    OceanBase CloudOceanBase EnterpriseOceanBase Community EditionOceanBase seekdb
    Resources
    DocsBlogLive 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.4.2
    iconOceanBase Database
    SQL - V 4.4.2
    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

    Drop a materialized view

    Last Updated:2026-04-02 06:23:57  Updated
    share
    What is on this page
    Considerations
    Privilege requirements
    Syntax
    Parameters
    Examples
    References

    folded

    share

    Considerations

    • When you drop a materialized view, it is not moved to the recycle bin.
    • If materialized view logs are created on the base table (ordinary table or materialized view) of the materialized view, you must drop the materialized view logs on the base table before you drop the base table. Otherwise, an error is returned.

    Privilege requirements

    To drop a materialized view, you must have the DROP TABLE privilege. For more information about privileges in OceanBase Database, see Privilege types in MySQL-compatible mode.

    Syntax

    DROP MATERIALIZED VIEW [IF EXISTS] materialized_view_list [opt_drop_behavior];
    
    materialized_view_list:
        [ database. ]materialized_view [,[ database. ]materialized_view]...
    
    opt_drop_behavior:
        RESTRICT | CASCADE
    

    Parameters

    Parameter
    Description
    IF EXISTS Optional. If you specify IF EXISTS, an error will not be returned if the materialized view to be dropped does not exist; otherwise, an error will be returned if the materialized view to be dropped does not exist.
    database. Optional. Specifies the database where the materialized view is located. If you omit database., the current database is used by default.
    materialized_view Specifies the name of the materialized view.
    RESTRICT | CASCADE Optional. Specifies the behavior of the drop operation.
    • CASCADE is the default value. It specifies to drop the materialized view and all objects that depend on it.
    • RESTRICT specifies to drop the materialized view only if no objects depend on it.

    Examples

    The following examples show how to create a materialized view, query materialized views, and drop a materialized view.

    1. Create a table named test_tbl1 as the base table of the materialized view.

      CREATE TABLE test_tbl1 (col1 INT PRIMARY KEY, col2 VARCHAR(20), col3 INT);
      
    2. Create a materialized view named mv_test_tbl1 based on the test_tbl1 table.

      CREATE MATERIALIZED VIEW mv_test_tbl1(PRIMARY KEY (col1))
          AS SELECT col1, col2
             FROM test_tbl1;
      
    3. Create a materialized view log on the mv_test_tbl1 materialized view.

      CREATE MATERIALIZED VIEW LOG ON mv_test_tbl1
          WITH PRIMARY KEY (col2) INCLUDING NEW VALUES;
      
    4. Create a nested materialized view named mv_mv_test_tbl1 based on the mv_test_tbl1 materialized view.

      CREATE MATERIALIZED VIEW mv_mv_test_tbl1
          AS SELECT col1
             FROM mv_test_tbl1;
      
    5. View information about all materialized views.

      SELECT owner, mview_name, container_name, query, refresh_mode
      FROM oceanbase.DBA_MVIEWS;
      

      The return result is as follows:

      +---------+-----------------+-----------------+-----------------------------------------------------------------------------------------------------------------+--------------+
      | owner   | mview_name      | container_name  | query                                                                                                           | refresh_mode |
      +---------+-----------------+-----------------+-----------------------------------------------------------------------------------------------------------------+--------------+
      | db_test | mv_mv_test_tbl1 | mv_mv_test_tbl1 | select `mv_test_tbl1`.`col1` AS `col1` from `db_test`.`mv_test_tbl1` `mv_test_tbl1`                             | DEMAND       |
      | db_test | mv_test_tbl1    | mv_test_tbl1    | select `db_test`.`test_tbl1`.`col1` AS `col1`,`db_test`.`test_tbl1`.`col2` AS `col2` from `db_test`.`test_tbl1` | DEMAND       |
      +---------+-----------------+-----------------+-----------------------------------------------------------------------------------------------------------------+--------------+
      2 rows in set
      
    6. Drop the mv_mv_test_tbl1 materialized view.

      DROP MATERIALIZED VIEW mv_mv_test_tbl1;
      

      The return result is as follows:

      Query OK, 0 rows affected
      
    7. Drop the mv_test_tbl1 materialized view.

      Notice

      If materialized view logs are created on the base table (ordinary table or materialized view) of the materialized view, you must drop the materialized view logs on the base table before you drop the base table. Otherwise, an error is returned.

      DROP MATERIALIZED VIEW mv_test_tbl1;
      

      The return result is as follows:

      ERROR 1235 (0A000): drop table required by materialized view refresh is not supported
      
    8. Drop the materialized view logs on the mv_test_tbl1 materialized view.

      DROP MATERIALIZED VIEW LOG ON mv_test_tbl1;
      

      The return result is as follows:

      Query OK, 0 rows affected
      
    9. Drop the mv_test_tbl1 materialized view again.

      DROP MATERIALIZED VIEW mv_test_tbl1;
      

      The return result is as follows:

      Query OK, 0 rows affected
      

    References

    • Overview of materialized views
    • Materialized view logs
    • Create a materialized view
    • Refresh a materialized view
    • Query rewrite by using materialized views
    • Query materialized views

    Previous topic

    Modify the attributes of a materialized view
    Last

    Next topic

    Resource isolation for materialized views
    Next
    What is on this page
    Considerations
    Privilege requirements
    Syntax
    Parameters
    Examples
    References