Generally, you can run CREATE TABLE to create tables in DLA. For example, to create a mapping table in DLA for a MongoDB collection, run the following statement:
create external table dla_person (
id int,
title varchar(127),
age int,
create_time timestamp
)TBLPROPERTIES (
TABLE_MAPPING = 'person',
COLUMN_MAPPING = 'title,name'
);
The CREATE statement must include all the fields in the person collection of the MongoDB database. If there are dozens or even hundreds of fields in the business-specific collection, it is time-consuming to manually enter these fields. To facilitate your operations, DLA provides the CREATE TABLE LIKE MAPPING function. When you create a table using CREATE TABLE LIKE MAPPING, you only need to specify the collection name or table name. DLA automatically queries a piece of sample data in the MongoDB collection, analyzes the fields and field types in the sample data, generates the corresponding table creation statement, and creates the table.