云数据库 GAUSSDB-创建GDS外表:任务示例

时间:2024-01-23 20:09:25

任务示例

除了以下示例,更多外表创建的示例请参考示例

  • 示例1:创建GDS外表foreign_tpcds_reasons,数据格式为 CS V。
    1
    2
    3
    4
    5
    6
    7
    postgres=# CREATE FOREIGN TABLE foreign_tpcds_reasons
    (
      r_reason_sk integer not null,
      r_reason_id char(16) not null,
      r_reason_desc char(100)
    )
     SERVER gsmpp_server OPTIONS (location 'gsfs://192.168.0.90:5000/* | gsfs://192.168.0.91:5000/*', FORMAT 'CSV',MODE 'Normal', ENCODING 'utf8', DELIMITER E'\x08', QUOTE E'\x1b', NULL '');
    
  • 示例2:创建GDS导入外表foreign_tpcds_reasons_SSL,使用SSL加密传输的模式传输,数据格式为CSV。
    1
    2
    3
    4
    5
    6
    7
    postgres=# CREATE FOREIGN TABLE foreign_tpcds_reasons_SSL
    (
      r_reason_sk integer not null,
      r_reason_id char(16) not null,
      r_reason_desc char(100)
    )
     SERVER gsmpp_server OPTIONS (location 'gsfss://192.168.0.90:5000/* | gsfss://192.168.0.91:5000/*', FORMAT 'CSV',MODE 'Normal', ENCODING 'utf8', DELIMITER E'\x08', QUOTE E'\x1b', NULL '');
    
  • 示例3:创建GDS外表foreign_tpcds_reasons,数据格式为TEXT。
    1
    2
    3
    4
    5
    6
    postgres=# CREATE FOREIGN TABLE foreign_tpcds_reasons
    (
      r_reason_sk integer not null,
      r_reason_id char(16) not null,
      r_reason_desc char(100)
    ) SERVER gsmpp_server OPTIONS (location 'gsfs://192.168.0.90:5000/* | gsfs://192.168.0.91:5000/*', FORMAT 'TEXT', delimiter E'\x08',  null '',reject_limit '2',EOL '0x0D') WITH err_foreign_tpcds_reasons;
    
  • 示例4:创建GDS外表foreign_tpcds_reasons,数据格式为FIXED。
    1
    2
    3
    4
    5
    6
    postgres=# CREATE FOREIGN TABLE foreign_tpcds_reasons
    (
      r_reason_sk       integer      position(1,2),
      r_reason_id       char(16)     position(3,16),
      r_reason_desc     char(100)    position(19,100)
    ) SERVER gsmpp_server OPTIONS (location 'gsfs://192.168.0.90:5000/*', FORMAT 'FIXED', ENCODING 'utf8',FIX '119');
    
support.huaweicloud.com/devg-v1-gaussdb/gaussdb_devg_0191.html