Managed Catalog

更新时间:
复制 MD 格式

A Managed Catalog is the built-in data catalog of AnalyticDB for MySQL. It manages the databases and tables that live inside the instance. In addition, external databases created with CREATE EXTERNAL DATABASE and external tables mapped with CREATE EXTERNAL TABLE (for example, tables that reference OSS, Hive, or MaxCompute data sources) also have their metadata managed by the adb Managed Catalog. Each instance contains exactly one Managed Catalog, fixed-named adb.

Limits

  • The Managed Catalog name is fixed as adb and cannot be changed.

  • You cannot create additional Managed Catalogs.

  • Requires AnalyticDB for MySQL 3.2.7 or later.

Query data in the Managed Catalog

  1. Connect to AnalyticDB for MySQL.

    • Connecting through a MySQL client opens the session in the adb catalog by default.

    • Connecting through JDBC, you can specify the database in the connection string: jdbc:mysql://<host>:<port>/adb.<db_name>. If the catalog is omitted, adb is used.

  2. (Optional) List the databases in the instance:

    SHOW DATABASES;
    -- or specify the catalog explicitly
    SHOW DATABASES FROM adb;

    SHOW DATABASES returns a column named Database. When specifying the catalog explicitly (SHOW DATABASES FROM adb), the column is named Schema.

  3. (Optional) Switch the active database:

    USE <db_name>;
    
    -- To specify both the catalog and the database
    USE adb.<db_name>;
  4. Query a table:

    SELECT * FROM <table_name>;

    If you have not picked a database in the previous steps, address the table directly with two- or three-part names:

    SELECT * FROM <db_name>.<table_name>;
    -- or
    SELECT * FROM adb.<db_name>.<table_name>;

Example

To query data in adb_db.adb_table, use any of the following:

-- Option 1: USE the database, then a one-part name
USE adb_db;
SELECT * FROM adb_table LIMIT 1;

-- Option 2: two-part name (current catalog is implied)
SELECT * FROM adb_db.adb_table LIMIT 1;

-- Option 3: three-part name (catalog made explicit)
SELECT * FROM adb.adb_db.adb_table LIMIT 1;

Related documents