本示例中dla_table_1、dla_table_2分别与AnalyticDB中的shipping、order_table表信息一致。
-
登录DLA控制台。
-
单击左侧导航栏的SQL访问点,然后登录DMS创建OSS Schema。
CREATE SCHEMA oss_data_schema with DBPROPERTIES( catalog='oss', location = 'oss://oss_bucket_name/table/' );
-
catalog='oss'
:指定创建的是OSS Schema。 -
location:数据文件所在的OSS Bucket的目录,需以
/
结尾表示目录。后续建表的LOCATION所指向的数据文件,必须在这个OSS目录下。本示例中table就是OSS中存放文件的Object。
-
创建OSS表
CREATE EXTERNAL TABLE IF NOT EXISTS dla_table_1 (
id bigint NOT NULL COMMENT '',
origin_state varchar NOT NULL COMMENT '',
origin_zip varchar NOT NULL COMMENT '',
destination_state varchar NOT NULL COMMENT '',
destination_zip varchar NOT NULL COMMENT '',
package_weight int NOT NULL COMMENT ''
)
ROW FORMAT DELIMITED FIELDS TERMINATED BY '|'
STORED AS TEXTFILE
LOCATION 'oss://oss_bucket_name/table/';
CREATE EXTERNAL TABLE IF NOT EXISTS dla_table_2 (
customer_id bigint NOT NULL COMMENT '',
order_id varchar NOT NULL COMMENT '',
order_time date NOT NULL COMMENT '',
order_amount double NOT NULL COMMENT '',
order_type varchar NOT NULL COMMENT '',
address varchar NOT NULL COMMENT '',
city varchar NOT NULL COMMENT '',
order_season bigint COMMENT '',
PRIMARY KEY (customer_id)
)
ROW FORMAT DELIMITED FIELDS TERMINATED BY '|'
STORED AS TEXTFILE
LOCATION 'oss://oss_bucket_name/table/';