ITPub博客

首页 > 数据库 > > 教程:使用GDS从远端服务器导入数据-步骤4:将数据导入GaussDB 200

教程:使用GDS从远端服务器导入数据-步骤4:将数据导入GaussDB 200

作者:GaussDB_数据库 时间:2020-01-14 10:08:02 0 删除 编辑
  1. 使用如下语句在GaussDB 200中创建目标表product_info,用于存储导入的数据。

    DROP TABLE IF EXISTS product_info;
    CREATE TABLE product_info
    (
    product_price integer not null,
    product_id char(30) not null,
    product_time date ,
    product_level char(10) ,
    product_name varchar(200) ,
    product_type1 varchar(20) ,
    product_type2 char(10) ,
    product_monthly_sales_cnt integer ,
    product_comment_time date ,
    product_comment_num integer ,
    product_comment_content varchar(200)
    )
    WITH (
    orientation = column,
    compression=middle
    )
    DISTRIBUTE BY hash (product_id);

  2. (可选)本例步骤1中没有创建索引,不用执行这一步。若目标表存在索引,在数据导入过程中,将增量更新索引信息,影响数据导入性能。建议在执行数据导入前,先删除目标表的索引。在数据导入完成后,再重新创建索引。

    1. 假定在导入表“product_info”上的“product_id”字段上存在普通索引“product_idx”。在执行数据导入前,请先删除相关索引。

      DROP INDEX product_idx;
      在数据导入完成后,重建索引。
    2. CREATE INDEX product_idx ON product_info(product_id);
       说明:

    在重建索引过程中,用户可以通过临时增加GUC参数“maintenance_work_mem”/“psort_work_mem”来加快索引的重建。

  3. 将数据源文件中的数据通过外表“product_info_ext”导入到表“product_info”中。
    INSERT INTO product_info SELECT * FROM product_info_ext ;
    出现以下信息,说明数据导入成功。
    INSERT  20
    执行SELECT命令查询目标表product_info,查看导入到GaussDB 200中的数据。
  4. SELECT count(*) FROM product_info;
    查询结果显示结果如下,表示导入成功。
    count 
    -------
    20
    (1 row)


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/69959250/viewspace-3150868/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2020-01-06

  • 博文量
    2907
  • 访问量
    19240