Updated on 2023-10-23 GMT+08:00

Exporting Data

Prerequisites

The IP addresses and ports of servers where CNs and DNs reside can connect to those of a GDS server.

Procedure

  1. Export data.

    1
    INSERT INTO [Foreign table name] SELECT * FROM [Source table name];
    
    • Create batch processing scripts to export data in parallel. The degree of parallelism depends on server resource usage. You can test several tables and monitor resource usage to determine whether to increase or reduce the amount. Common resource monitoring commands include top for monitoring memory and CPU usage, iostat for monitoring I/O usage, and sar for monitoring networks.
    • Only a single internal table can be exported at a time. Multi-table join is not supported during export. Results of the aggregation, sort, subquery, and limit operations on a single table also cannot be exported.
    • In this version, GDS export supports CN RETRY. (The current feature is a lab feature. Contact Huawei engineers for technical support before using it.) CN RETRY is triggered when a network error occurs due to a DN or GTM fault. Ensure that the GDS version is the same as or later than the kernel version.

Examples

  • Example 1: Export data from the reasons table to data files through the foreign table foreign_tpcds_reasons.
    1
    openGauss=# INSERT INTO foreign_tpcds_reasons SELECT * FROM reasons;
    
  • Example 2: Export part of the data to data files by specifying the filter condition r_reason_sk =1.
    1
    openGauss=# INSERT INTO foreign_tpcds_reasons SELECT * FROM reasons WHERE r_reason_sk=1;
    
  • Example 3: Data of a special type, such as RAW, is exported as a binary file, which cannot be recognized by the import tool. You need to use the RAWTOHEX() function to convert it to hexadecimal the format before export.
    1
    openGauss=# INSERT INTO foreign_blob_type_tab SELECT RAWTOHEX(c) FROM blob_type_tab;