EXPDB IMPDB匯出資料庫和匯入資料庫操作手冊

2022-10-17 13:18:06 字數 3154 閱讀 2529

查詢oracle的安裝路徑:echo $oracle_home;

操作步驟:

1.需要在資料庫建立hec_dump_dir類似的directory(此命令需要dba許可權,例如:在mastest資料庫中,需要以masdemo使用者身份登陸.)

- -create directory

=》create or replace directory dump_dir_test as '/u01/oracle/oracle_test';

2.授權

=》grant read,write on directory dump_dir_test to hec2dev;

3.匯出(用su – oracle命令切換到oracle使用者下面,執行下面的語句, schemas為當前使用者)

=》expdp hec2dev/hec2dev directory=dump_dir_test dumpfile= logfile=dump_dir_

帶版本號匯出(從高版本匯出,匯入到低版本時需要帶版本號,點選pl/sql的命令視窗或者sqlplus hec2dev/hec2dev@mastest,在最上面都會有版本號):

=》expdp hec2dev/ hec2dev directory=dump_dir_test dumpfile= logfile=dump_dir_ schemas=autohec2test version='10.2.0.

1.0'

可能出現的問題:

(1)指定的net服務名不正確。

解決方法:因為沒有配置指定oracle_sid,可以用命令:echo $oracle_sid進行檢視是否指定了oracle_sid,若沒有,可以通過命令:

export oracle_sid=mastest(要匯出資料庫的sid)解決。

(2)中文亂碼。

解決方法:將編碼方式由utf-8改為簡體中文。

(3)無法開啟日誌檔案。

解決方法:這是因為由create or replace directory dump_dir_test as '/u01/oracle/oracle_test';這個命令建立的oracle_test資料夾的user和group均為root,應該改為:oracle和dba.

故可以先切換到root使用者下,再呼叫命令:chown oracle:dba oracle_test;可以將oracle_test的使用者和組改為oracle和dba.

4.建立表空間

=》create tablespace tablespace_name datafile '/u01/oradata/mastest/' size 50m

autoextend on ;

名詞解釋:datafile:存放表空間的實體地址。

注:表空間一般都放在oradata這個目錄下面(/u01下)。

補充:建立臨時表空間:create temporary tablespace heczte_temp

tempfile '/u01/oradata/mastest/heczte_'

size 50m autoextend on;

建立物理表空間:create tablespace heczte_data

logging

datafile '/u01/oradata/mastest/heczte_'

size 50m autoextend on;

刪除表空間:drop tablespace tablespace_name including contents and datafiles;

5.建立使用者

drop user test cascade;

create user test identified by test default tablespace test;

(create user username identified by password default tablespace tablespace_name )

grant connect to test;

grant alter session to test;

grant create any context to test;

grant create procedure to test;

grant create sequence to test;

grant create session to test;

grant create synonym to test;

grant create table to test;

grant create type to test;

grant create user to test;

grant create view to test;

grant create any table to test;

grant debug connect session to test;

grant query rewrite to test;

grant select any dictionary to test;

grant unlimited tablespace to test;

--重要

grant exp_full_database to test;

grant imp_full_database to test;

grant create materialized view to test;

6.授權

grant read,write on directory dump_dir_test to test;

注意:如何查詢目錄,select * from dba_directories;

7.匯入

impdp test/test remap_tablespace=hec2dev:test remap_schema=hec2dev:test directory=dump_dir_test dumpfile= logfile=dump_dir_test:

hec2dev1101_

可能出現的問題:

(1)路徑錯誤。注意directory=dump_dir_test的路徑及其logfile的路徑。還有就是要注意remap_tablespace=hec2dev:

test,hec2dev是匯出時的資料庫的表空間,test是後來自己建立的表空間(第四步),如果當時不知道匯出時資料庫的表空間,執行一下該匯入語句,報錯了也就知道了。

資料庫種類與資料庫結構

2 網狀結構模型 某醫院醫生 病房和病人之間的聯絡。即每個醫生負責 三個病人,每個病房可住一到四個病人。如果將醫生看成是乙個資料集合,病人和病房分別是另外兩個資料集合,那麼醫生 病人和病房的比例關係就是m n p 即m個醫生,n個病人,p間病房 這種資料結構就是網狀資料結構,它的一般結構模型,記錄r...

資料控制資料庫

資料庫實驗報告 實驗四實驗題目 資料控制 指導老師 李萍 專業班級 電腦科學與技術系1001班 姓名 劉萌 2010100155 2012年 11月10日 實驗型別 驗證實驗室 軟體實驗室一 一 實驗題目 資料控制 安全性和完整性 二 實驗目的和要求 理解sql server的使用者與許可權管理機制...

資料庫作業

資料庫習題 1 資料模型通常由 和 3要素組成。2 資料邏輯模型通常分為和 4種。3 資料操作描述的是系統的動態特性,主要包括和 4種操作。4 關係模型中,完整性約束主要是和 5 關係資料庫系統是以 為基礎的資料庫系統。6 從資料庫管理系統的角度劃分資料庫系統體系結構,可分為和 3層。7 有了 外模...