Oracle匯入遠端資料庫資料及匯入

2021-08-31 15:09:53 字數 3271 閱讀 1922

exp本地匯出與imp本地匯入

exp命令:

1 exp username/psw@test file=d:test.dmp full=y

2 exp username/psw@test file=d:test.dmp owner=(ly)

3 exp username/psw@test file= d:test.dmp tables=(grid1,grid2)

1其中一是將test(與某一資料庫對應的oracle服務名)資料庫進行整體匯出

2將屬於使用者ly的所有表匯出

3將表grid1,與grid2匯出

imp命令:

1 imp system/psw@test file=d:test.dmp

2 imp system/psw@test full=y file=d:test.dmp ignore=y

3 imp system/psw@test file=d:test.dmp tables=(grid1)ignore=y表示如果被匯入的資料庫中某個表已經存在就忽略不匯入那個表

3表示只匯入grid1這個表

在匯入匯出前要先測試下對應的資料庫是否是通的:tnsping test來測試,同樣test是服務名

所有命令可在cmd下執行

用exp/imp遠端運算元據庫

對oracle資料庫進行遠端操作,假設資料庫在192.168.1.110上,具體方法如下:

一、在客戶端建立和服務端對應的服務名

方法1:

修改tnsnames.ora檔案

加入遠端伺服器的命名:

sql**

test_orcl =

(description =

(address_list =

(address = (protocol = tcp)(host = 192.168.1.110)(port = 1521))

)

(connect_data =

(service_name = orcl)

)

) 方法2:

在oracle客戶端,開啟net manager。

建立乙個服務命名test_orcl,主機ip為:192.168.1.110,服務名orcl,埠1521

二、測試遠端伺服器是否暢通

進入到cmd後,執行命令:tnsping test_orcl。

三、遠端運算元據庫

匯出:sql**

1:exp username/password@test_orcl file=bak_filepath

2:exp username/password@test_orcl full=y file=bak_filepath

username 使用者名稱,password 密碼,test_orcl 客服端服務名,bak_filepath 備份檔案存放的路徑

匯入:sql**

1:imp username/password@test_orcl file=bak_filepath full=y

2:imp username/password@test_orcl/database_name file=bak_filepath full=y

3:imp username/password@test_orcl file=bak_filepath fromuser=fromadmin touser=toadmin

username 使用者名稱,password 密碼,test_orcl 客服端服務名,bak_filepath 備份檔案存放的路徑

fromadmin 備份資料的使用者名稱,toadmin 還原資料庫的使用者名稱。database_name 還原到那個資料庫上

full=y 將資料庫整體匯出,包括表結構等。

匯入過程中可能要重新建立使用者:

給使用者增加匯入資料許可權的操作

第一,啟動sql*puls

第二,以system/manager登陸

第三,create user 使用者名稱 identified by 密碼 (如果已經建立過使用者,這步可以省略)

第四,grant create user,drop user,alter user ,create any view ,

drop any view,exp_full_database,imp_full_database,

dba,connect,resource,create session to 使用者名字

匯入過程可能要建立表空間等:

其要操縱乙個oracle資料庫中的資料,應該:   

1.被授予關於乙個或多個表空間中的resource特權;

2.被指定預設表空間;

3.被分配指定表空間的儲存空間使用份額;

4.被指定預設臨時段表空間。

drop user xuping cascade;

drop tablespace xuping including contents;

create tablespace xuping logging datafile 'f:\oracle\product\10.2.0\oradata\develop\xuping.ora' size 50m extent management local segment space management auto;;

create user xuping identified by xuping default tablespace xuping temporary tablespace temp;

grant connect,resource,dba to xuping;

匯入匯出例項:

cmd

exp hzbswcis/[email protected] file=e:/hzcis.dmp owner=hzbswcis

建立使用者和表空間

imp hzbswcis/hzbswcis@orcl file=e:/hzcis.dmp full=y

solaris下匯出部分表的資料,條件匯出:

exp user/pwd@dpdata file=/export/home/kaifa/hx.dmp tables=(store_in_head,store_in_list) query=\"where bill_id=\'k012i12010630\'\";
另見:oracle匯出使用者中的表,檢視等到另乙個使用者

oracle建立表空間和使用者授權

oracle建立表空間的語法:

Oracle資料庫遠端匯入 匯出

exp本地匯出與imp本地匯入 exp命令 1 exp username psw test file d test.dmp full y 2 exp username psw test file d test.dmp owner ly 3 exp username psw test file d t...

Oracle資料庫遠端匯入 匯出

exp本地匯出與imp本地匯入 exp命令 1 exp username psw test file d test.dmp full y 2 exp username psw test file d test.dmp owner ly 3 exp username psw test file d t...

Oracle資料庫遠端匯入 匯出

exp本地匯出與imp本地匯入 exp命令 1 exp username psw test file d test.dmp full y 2 exp username psw test file d test.dmp owner ly 3 exp username psw test file d t...