Vertica集群間資料的匯入匯出

2021-10-01 17:19:00 字數 3130 閱讀 3258

本文介紹vertica 不同集群間互相匯入匯出資料。導資料可以是先生成csv的資料檔案,然後

load 入庫,也可以是遠端連線到另外乙個集群,直接導資料。遠端連線導數需要開通防火牆埠

。匯出過程分為三個步驟:

connect 連線到目標資料庫。

export to vertica匯出資料。一次只能匯出乙個表。使用多個export語句匯出多個表或多個select語句的結果。所有語句使用到目標資料庫的相同連線。

disconnect 匯出操作完成後,與目標資料庫斷開連線。

匯出資料的例子

下面的示例演示了如何使用上面列出的三步過程來匯出資料。

首先,開啟與其他資料庫的連線,然後將整個表簡單匯出到目標資料庫中的相同表。

=

>

connect

to vertica testdb user dbadmin password ''

on'verttest01'

,5433

;connect

=> export to vertica testdb.customer_dimension from customer_dimension;

rows exported

---------------

23416(1

row)

以下語句演示使用簡單select語句匯出表的一部分。

=

> export to vertica testdb.ma_customers as

select customer_key, customer_name, annual_income

from customer_dimension where customer_state =

'ma'

;rows exported

---------------

3429(1

row)

該語句使用列列表將乙個表中的多個列匯出到目標資料庫表中的多個不同列。請記住,同時提供源列和目標列列表時,列數必須匹配。

=

> export to vertica testdb.people (name, gender, age)

from customer_dimension

(customer_name, customer_gender, customer_age)

;rows exported

---------------

23416(1

row)

(1行)

您還可以export to vertica與select at epoch latest表示式一起使用,以包括來自最新提交的dml事務的資料。

匯出完成後,切記一定要從資料庫斷開連線:

=

> disconnect testdb;

disconnect

您可以從另乙個vertica資料庫匯入表或表中的特定列。接收複製資料的表必須已經存在,並且其列與要從其他資料庫複製的列的資料型別匹配(或可以強制轉換為列)。如果早期版本是目標資料庫版本之前的最後乙個主要版本的版本,則可以從早期vertica版本中匯入資料。

匯入流程

匯入過程分為三個步驟:

connect 連線到包含要匯入的資料的資料庫。

copy from vertica將表資料匯入到目標資料庫。要從多個表匯入資料,請copy from vertica使用與源資料庫的相同連線發出多個語句。

disconnect 複製操作完成後,與源資料庫斷開連線。

匯入身份列

您可以按以下方式匯入標識(和自動遞增)列:

如果源表和目標表都具有乙個標識列,並且配置引數copyfromverticawithidentity設定為true(1),則無需列出它們。

如果源表有乙個標識列,但目標表沒有,則必須顯式列出源和目標列。

警告:未列出要匯出的身份列可能導致錯誤,因為身份列在目標表中將被解釋為丟失。

匯入列後,標識列的值不會自動增加。使用alter sequence進行更新。

該語句的預設行為是通過直接在源表中指定標識(和自動遞增)列來匯入它們。要全域性禁用此行為,請設定copyfromverticawithidentity配置引數,如配置引數中所述。

例子此示例演示如何連線到另乙個資料庫,將整個表的內容從源資料庫複製到當前資料庫中定義相同的表中,直接複製到ros中,然後關閉連線:

=

>

connect

to vertica vmart user dbadmin password ''

on'verttest01'

,5433

;connect

=> copy customer_dimension from vertica vmart.customer_dimension direct;

rows loaded

-------------

500000(1

row)

=> disconnect vmart;

disconnect

本示例演示將源資料庫中的表中的幾列複製到本地資料庫中的表中:

=

>

connect

to vertica vmart user dbadmin password ''

on'verttest01'

,5433

;connect

=> copy people (name, gender, age)

from vertica

vmart.customer_dimension (customer_name, customer_gender,

customer_age)

;rows loaded

-------------

500000(1

row)

=> disconnect vmart;

disconnect

參考:

exporting data to another vertica database

copying data from another vertica database

集群之間資料的遷移

場景 舊集群的資料要遷移到新集群上面 hadoop distcp option hdfs master ip 8020 hive warehouse db tab name hdfs master ip 8020 hive warehouse db tab name option的內容可以hadoo...

Hadoop集群間資料拷貝

有時候,我們需要做hadoop集群遷移時,要把大量儲存在hadoop集群上的資料也一併遷移過去。有2種方法可以使用 1.old hadoop cluster old local disks transmission new local disks new hadoop cluster 2.old h...

Elasticsearch集群間資料遷移

一 情況說明 將原來elasticsearch 6.4.2集群的資料遷移至現在的elasticsearch 7.2.0集群,遷移資料量大小在200g資料左右。二 遷移方案 1 使用elasticdump elasticdump是實現不同elasticsearch集群之間索引遷移的工具,基於npm包安...