The data of an external table is stored in a storage system outside the OceanBase cluster (such as local directories, object storage, or HDFS). The database only stores the metadata and access paths. After an external table is created, it can be used for operations such as SELECT, JOIN, and aggregation, just like a regular table. However, it is read-only and does not support DML, constraints, or indexes.
Differences from regular tables:
Feature |
External table |
Regular table |
|---|---|---|
| Data location | External storage | Inside OceanBase |
| Read/write | External tables are read-only: you can perform SELECT, but cannot execute DML operations such as INSERT, UPDATE, or DELETE. |
Read/write |
| Constraints and indexes | Not supported | Supported |
| Typical performance | Affected by the network and external systems | Faster local access |
Considerations
- Files are collected based on the
LOCATIONandPATTERNparameters during creation. New files require a refresh. For more information, see Manage external files and ALTER EXTERNAL TABLE. - For an external table partition with
PARTITION_TYPE = USER_SPECIFIED, you can add or delete the partitionLOCATIONby using ALTER EXTERNAL TABLE. Note that the ALTER capabilities in MySQL-compatible mode may vary; refer to the corresponding documentation. - A query will not report an error for deleted external files. Concurrently modifying an external file may result in unexpected outcomes.
External data access methods
Method |
Requires creating a table object? |
Typical scenarios |
Syntax and documentation entry |
|---|---|---|---|
| External table (CREATE EXTERNAL TABLE) | Yes | Frequent queries, JOINs with internal tables, managing file lists and partitions | CREATE EXTERNAL TABLE and Create and query external tables |
| FILES table function | No | Temporary exploration, one-time reading | FILES table function and URL external table (no metadata) |
Note
The complete list of parameters for the file format (FORMAT) is specified in CREATE EXTERNAL TABLE. For features such as External Catalog, refer primarily to the MySQL-compatible mode documentation. For Oracle compatible mode, refer to the actual supported features.
HDFS external table
To access HDFS, you must deploy the Java SDK environment for OceanBase Database and configure parameters such as ob_enable_java_env. For details, see CREATE EXTERNAL TABLE. For troubleshooting, see Troubleshooting guide for external tables.