sqoop与PG库导入导出数据
导入数据到Hive
sqoop import --connect jdbc:postgresql://172.66.6.666/radar5g4h --username postgres --password 1234 \ --query " select antenna_model,type,theta,gain from wcnos_antenna_beam where \$CONDITIONS " \ --target-dir table1 --delete-target-dir \ --hive-import --hive-database ott --hive-table table1 \ --null-string '\\N' \ --null-non-string '\\N' \ --fields-terminated-by "," \ -m 1
导出数据到PG库
sqoop export --connect jdbc:postgresql://172.66.6.666/radar5g4h --username postgres --password 1234 \ --table table1 \ --export-dir /user/hive/warehouse/ott.db/table1 \ --fields-terminated-by ',' \ --m 1 \ --input-null-string '\\N' --input-null-non-string '\\N'
sqoop到导入数据到PG库时,会通过select * from table 来确定表是否存在,如果不存在则抛出错误。