openGauss这么多工具?到底要选哪个?(65)

49 阅读1分钟

#openGauss #入门 #安装 #数据库 #开源

知识来源:docs-opengauss.osinfra.cn/zh/

  • ctl文件中不指定列类型,隐式类型转换(涉及隐式类型转换,建议加上兼容性参数)。

    // 建表
    create table test(mes int, mes1 text, mes2 float8, mes3 timestamp with time zone, mes4 INTEGER);
    // 数据文件
    cat load_support_transform.data
    1,mmoo,12.6789,Thu Jan 01 15:04:28 1970 PST,32767
    2,yyds,180.883,Thu Jun 21 19:00:00 2012 PDT,32768
    // 控制文件
    cat load_support_transform.ctl 
    Load Data
    TRUNCATE INTO TABLE test
    fields terminated by ','
    TRAILING NULLCOLS(
    mes,
    mes1 "mes1 || mes2",
    mes2 "mes2 + 1",
    mes3 "date_trunc('year', mes3)",
    mes4
    )
    // guc_param file
    cat test_guc.txt
    set a_format_copy_version='s1';
    set a_format_dev_version='s2';
    set a_format_version='10c';
    //执行导入
    gs_loader -p xxx host=xxx control=load_support_transform.ctl data=load_support_transform.data -d testdb -W xxx guc_param=test_guc.txt 
    // 导入结果:导入成功
    select * from test;
     mes |    mes1     |  mes2   |          mes3          | mes4  
    -----+-------------+---------+------------------------+-------
       1 | mmoo12.6789 | 13.6789 | 1970-01-01 00:00:00+08 | 32767
       2 | yyds180.883 | 181.883 | 2012-01-01 00:00:00+08 | 32768
    

#openGauss #入门 #安装 #数据库 #开源

知识来源:docs-opengauss.osinfra.cn/zh/