欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

一篇文章教會(huì)你使用gs_restore導(dǎo)入數(shù)據(jù)

 更新時(shí)間:2022年09月05日 16:04:07   作者:大話數(shù)據(jù)庫(kù)  
gs_restore是GaussDB(DWS)提供的針對(duì)gs_dump導(dǎo)出數(shù)據(jù)的導(dǎo)入工具,下面這篇文章主要給大家介紹了關(guān)于如何通過(guò)一篇文章教會(huì)你使用gs_restore導(dǎo)入數(shù)據(jù)的相關(guān)資料,需要的朋友可以參考下

背景信息

gs_restore是openGauss提供的針對(duì)gs_dump導(dǎo)出數(shù)據(jù)的導(dǎo)入工具。通過(guò)此工具可將由gs_dump生成的導(dǎo)出文件進(jìn)行導(dǎo)入。

gs_restore工具由操作系統(tǒng)用戶omm執(zhí)行。

主要功能包含:

  • 導(dǎo)入到數(shù)據(jù)庫(kù)

如果連接參數(shù)中指定了數(shù)據(jù)庫(kù),則數(shù)據(jù)將被導(dǎo)入到指定的數(shù)據(jù)庫(kù)中。其中,并行導(dǎo)入必須指定連接的密碼。導(dǎo)入時(shí)生成列會(huì)自動(dòng)更新,并像普通列一樣保存。

  • 導(dǎo)入到腳本文件

如果未指定導(dǎo)入數(shù)據(jù)庫(kù),則創(chuàng)建包含重建數(shù)據(jù)庫(kù)所必須的SQL語(yǔ)句腳本并寫(xiě)入到文件或者標(biāo)準(zhǔn)輸出。等效于直接使用gs_dump導(dǎo)出為純文本格式。

命令格式

gs_restore [OPTION]... FILE

說(shuō)明:

  • FILE沒(méi)有短選項(xiàng)或長(zhǎng)選項(xiàng)。用來(lái)指定歸檔文件所處的位置。
  • 作為前提條件,需輸入dbname或-l選項(xiàng)。不允許用戶同時(shí)輸入dbname和-l選項(xiàng)。
  • gs_restore默認(rèn)是以追加的方式進(jìn)行數(shù)據(jù)導(dǎo)入。為避免多次導(dǎo)入造成數(shù)據(jù)異常,在進(jìn)行導(dǎo)入時(shí),建議使用“-c” 參數(shù),在重新創(chuàng)建數(shù)據(jù)庫(kù)對(duì)象前,清理(刪除)已存在于將要還原的數(shù)據(jù)庫(kù)中的數(shù)據(jù)庫(kù)對(duì)象。
  • 日志打印無(wú)開(kāi)關(guān),若需隱藏日志,請(qǐng)將日志重定向到日志文件。若恢復(fù)表數(shù)據(jù)時(shí),數(shù)據(jù)量很大,會(huì)分批恢復(fù),因此會(huì)多次出現(xiàn)“表數(shù)據(jù)已完成導(dǎo)入”的日志。

表 1 常用參數(shù)說(shuō)明

參數(shù)

參數(shù)說(shuō)明

舉例

-U

連接數(shù)據(jù)庫(kù)的用戶名。

-U jack

-W

指定用戶連接的密碼。

  • 如果主機(jī)的認(rèn)證策略是trust,則不會(huì)對(duì)數(shù)據(jù)庫(kù)管理員進(jìn)行密碼驗(yàn)證,即無(wú)需輸入-W選項(xiàng);
  • 如果沒(méi)有-W選項(xiàng),并且不是數(shù)據(jù)庫(kù)管理員,會(huì)提示用戶輸入密碼。

-W abcd@123

-d

連接數(shù)據(jù)庫(kù)dbname,并直接將數(shù)據(jù)導(dǎo)入到該數(shù)據(jù)庫(kù)中。

-d backupdb

-p

指定服務(wù)器所偵聽(tīng)的TCP端口或本地Unix域套接字后綴,以確保連接。

-p 8000

-e

當(dāng)發(fā)送SQL語(yǔ)句到數(shù)據(jù)庫(kù)時(shí)如果出現(xiàn)錯(cuò)誤,則退出。默認(rèn)狀態(tài)下會(huì)忽略錯(cuò)誤任務(wù)并繼續(xù)執(zhí)行導(dǎo)入,且在導(dǎo)入后會(huì)顯示一系列錯(cuò)誤信息。

-

-c

在重新創(chuàng)建數(shù)據(jù)庫(kù)對(duì)象前,清理(刪除)已存在于將要導(dǎo)入的數(shù)據(jù)庫(kù)中的數(shù)據(jù)庫(kù)對(duì)象。

-

-s

只導(dǎo)入模式定義,不導(dǎo)入數(shù)據(jù)。當(dāng)前的序列值也不會(huì)被導(dǎo)入。

-

示例

特例:執(zhí)行g(shù)sql程序,使用如下選項(xiàng)導(dǎo)入由gs_dump/gs_dumpall生成導(dǎo)出文件夾(純文本格式)的MPPDB_backup.sql文件到postgres數(shù)據(jù)庫(kù)。

gsql -d postgres -p 15400 -W Bigdata@123 -f /home/omm/test/MPPDB_backup.sql
SET
SET
SET
SET
SET
ALTER TABLE
ALTER TABLE
ALTER TABLE
ALTER TABLE
ALTER TABLE
CREATE INDEX
CREATE INDEX
CREATE INDEX
SET
CREATE INDEX
REVOKE
REVOKE
GRANT
GRANT
total time: 30476  ms

gs_restore用來(lái)導(dǎo)入由gs_dump生成的導(dǎo)出文件。

示例1:執(zhí)行g(shù)s_restore,將導(dǎo)出的MPPDB_backup.dmp文件(自定義歸檔格式)導(dǎo)入到postgres數(shù)據(jù)庫(kù)。

gs_restore -W Bigdata@123 backup/MPPDB_backup.dmp -p 15400 -d postgres
gs_restore: restore operation successful
gs_restore: total time: 13053  ms

示例2:執(zhí)行g(shù)s_restore,將導(dǎo)出的MPPDB_backup.tar文件(tar格式)導(dǎo)入到postgres數(shù)據(jù)庫(kù)。

gs_restore backup/MPPDB_backup.tar -p 15400 -d postgres 
gs_restore[2017-07-21 19:16:26]: restore operation successful
gs_restore[2017-07-21 19:16:26]: total time: 21203  ms

示例3:執(zhí)行g(shù)s_restore,將導(dǎo)出的MPPDB_backup文件(目錄格式)導(dǎo)入到postgres數(shù)據(jù)庫(kù)。

gs_restore backup/MPPDB_backup -p 15400 -d postgres
gs_restore[2017-07-21 19:16:26]: restore operation successful
gs_restore[2017-07-21 19:16:26]: total time: 21003  ms

示例4:執(zhí)行g(shù)s_restore,使用自定義歸檔格式的MPPDB_backup.dmp文件來(lái)進(jìn)行如下導(dǎo)入操作。 導(dǎo)入PUBLIC模式下所有對(duì)象的定義和數(shù)據(jù)。在導(dǎo)入時(shí)會(huì)先刪除已經(jīng)存在的對(duì)象,如果原對(duì)象存在跨模式的依賴則需手工強(qiáng)制干預(yù)。

gs_restore backup/MPPDB_backup.dmp -p 15400 -d postgres -e -c -n PUBLIC
gs_restore: [archiver (db)] Error while PROCESSING TOC:
gs_restore: [archiver (db)] Error from TOC entry 313; 1259 337399 TABLE table1 gaussdba
gs_restore: [archiver (db)] could not execute query: ERROR:  cannot drop table table1 because other objects depend on it
DETAIL:  view t1.v1 depends on table table1
HINT:  Use DROP ... CASCADE to drop the dependent objects too.
    Command was: DROP TABLE public.table1;

手工刪除依賴,導(dǎo)入完成后再重新創(chuàng)建。

gs_restore backup/MPPDB_backup.dmp -p 15400 -d postgres -e -c -n PUBLIC
gs_restore[2017-07-21 19:16:26]: restore operation successful
gs_restore[2017-07-21 19:16:26]: total time: 2203  ms

示例5:執(zhí)行g(shù)s_restore,使用自定義歸檔格式的MPPDB_backup.dmp文件來(lái)進(jìn)行如下導(dǎo)入操作。只導(dǎo)入PUBLIC模式下表table1的定義。

gs_restore backup/MPPDB_backup.dmp -p 15400 -d postgres -e -c -s -n PUBLIC -t table1
gs_restore[2017-07-21 19:16:26]: restore operation successful
gs_restore[2017-07-21 19:16:26]: total time: 21000  ms

示例6:執(zhí)行g(shù)s_restore,使用自定義歸檔格式的MPPDB_backup.dmp文件來(lái)進(jìn)行如下導(dǎo)入操作。只導(dǎo)入PUBLIC模式下表table1的數(shù)據(jù)。

gs_restore backup/MPPDB_backup.dmp -p 15400 -d postgres -e -a -n PUBLIC -t table1
gs_restore[2017-07-21 19:16:26]: restore operation successful
gs_restore[2017-07-21 19:16:26]: total time: 20203  ms

總結(jié)

到此這篇關(guān)于使用gs_restore導(dǎo)入數(shù)據(jù)的文章就介紹到這了,更多相關(guān)gs_restore導(dǎo)入數(shù)據(jù)內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評(píng)論