OceanBase logo

OceanBase

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

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

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

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
    DocsBlogLive DemosTraining & Certification
    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
    SQL
    KV
    • 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

    Dependencies between database objects

    Last Updated:2024-11-11 07:37:15  Updated
    share
    What is on this page
    share

    The relationships and references between database objects are known as dependencies. This topic describes how to create and view dependencies between database objects in OceanBase Database's MySQL mode.

    Some types of schema objects can reference other objects in their definitions. For example, a view can be defined as a query that references a table or another view. If object B is referenced in the definition of object A, A is a dependent object of B, and B is a referenced object of A.

    The dependency relationships between views and tables, as well as views and other views, are described in a MySQL tenant. These relationships can be queried using the VIEW_TABLE_USAGE view in the information_schema database.

    Example 1: Create a view named view2 that references the tbl1 table and the view1 view.

    obclient> CREATE TABLE tbl1(col1 INT, col2 INT);
    Query OK, 0 rows affected
    
    obclient> CREATE TABLE tbl2 (col1 INT, col2 INT);
    Query OK, 0 rows affected
    
    obclient> CREATE VIEW view1 AS SELECT * FROM tbl2;
    Query OK, 0 rows affected
    
    obclient> CREATE VIEW view2 AS SELECT t.col1 AS col1, t.col2 AS col2 FROM tbl1 t, view1 v WHERE
          t.col1 = v.col2;
    Query OK, 0 rows affected
    

    Example 2: Query the dependencies between database objects by using the VIEW_TABLE_USAGE view of the information_schema database.

    obclient> SELECT * FROM information_schema.VIEW_TABLE_USAGE;
    +--------------+-------------+-----------+--------------+------------+---------------+
    | VIEW_CATALOG | VIEW_SCHEMA | VIEW_NAME | TABLE_SCHEMA | TABLE_NAME | TABLE_CATALOG |
    +--------------+-------------+-----------+--------------+------------+---------------+
    | def          | test        | view1        | test         | tbl2         | def           |
    | def          | test        | view2        | test         | view1         | def           |
    | def          | test        | view2        | test         | tbl1         | def           |
    +--------------+-------------+-----------+--------------+------------+---------------+
    3 rows in set
    

    In the preceding example, the dependencies between database objects are returned in the query result of the view. For example, the view1 view references the tbl2 table, and the view2 view references the tbl1 table and the view1 view.

    The dependency relationships between views and tables, as well as views and other views, can be very useful in some scenarios. For example, in a database migration scenario, it may be necessary to recreate schema objects in another database. If the schema object that needs to be recreated is a view, it is necessary to recreate the other objects that the view depends on before recreating the view itself. Otherwise, an error will occur during the recreation process stating that the dependent objects do not exist. By obtaining the dependency relationships between views and tables, as well as views and other views, it becomes easier to complete the task of recreating the objects.

    Previous topic

    Database object storage
    Last

    Next topic

    Overview
    Next