全部產品
Search
文件中心

Dataphin:步驟一:準備工作

更新時間:Mar 15, 2025

進行離線數倉建設前您需完成相關雲資源的準備。雲資源準備包括MaxCompute計算源的開通與配置、以及資料來源的準備。本文將指導您完成本教程的雲資源準備工作。

步驟一:MaxCompute開通與配置

主流程

描述

操作指導

開通MaxCompute

購買MaxCompute。

開通MaxCompute

建立MaxCompute專案空間

建立MaxCompute專案空間,專案名稱為dataphin_tutorial

重要

MaxCompute使用全域的專案空間,已建立的專案空間不支援再建立。建議使用dataphin_tutorial_001等方式建立。

建立MaxCompute專案

設定Dataphin計算引擎

設定Dataphin的計算引擎為MaxCompute。

設定Dataphin執行個體的計算引擎為MaxCompute

步驟二:準備資料來源

  1. 通過RDS建立MySQL8.0執行個體,擷取RDS執行個體ID,並在RDS控制台添加白名單,詳情請參見建立RDS MySQL執行個體。本教程中RDS資料來源名稱以dataphin_tutorial為例。

  2. 登入MySQL執行個體,並使用以下命令建立資料庫及資料表。

    create database dataphin; //建立dataphin資料庫
    
    //產品表
    CREATE TABLE product (
    product_id INT PRIMARY KEY COMMENT '產品ID',
    product_name VARCHAR(100) COMMENT '產品名稱',
    product_category VARCHAR(100) COMMENT '產品類別',
    product_price DECIMAL(10, 2) COMMENT '產品價格'
    );
    
    //插入產品表資料
    INSERT INTO product(product_id, product_name, product_category, product_price) values(1001,'西湖龍井','綠茶',20);
    INSERT INTO product(product_id, product_name, product_category, product_price) values(1002,'貴州湄潭','綠茶',22);
    INSERT INTO product(product_id, product_name, product_category, product_price) values(1003,'大紅袍','烏龍茶',100);
    
    //客戶表
    CREATE TABLE customer (
    customer_id INT PRIMARY KEY COMMENT '客戶ID',
    customer_name VARCHAR(100) COMMENT '產品姓名'
    );
    
    //插入客戶資料
    INSERT INTO customer(customer_id, customer_name) VALUES (1001001,'閃閃');
    INSERT INTO customer(customer_id, customer_name) VALUES  (1001002,'毛毛');
    INSERT INTO customer(customer_id, customer_name) VALUES  (1001003,'西西');
    
    //訂單表
    CREATE TABLE orders (
    order_id INT PRIMARY KEY COMMENT '訂單ID',
    customer_id INT COMMENT '客戶ID',
    product_id INT COMMENT '產品ID',
    order_time DATE COMMENT '訂單日期',
    payment_amount DECIMAL(10, 2) COMMENT '訂單金額',
    FOREIGN KEY (product_id) REFERENCES product(product_id),
    FOREIGN KEY (customer_id) REFERENCES customer(customer_id)
    );
    
    //插入訂單資料
    INSERT INTO orders(order_id, customer_id, product_id, order_time, payment_amount) VALUES  (003,1001001,1001,curdate(),20);
    INSERT INTO orders(order_id, customer_id, product_id, order_time, payment_amount) VALUES  (004,1001001,1001,curdate(),20);