oralce導入導出總結

實際環境中我們經常會遇到建一臺服務器A用戶環境搬到另外一套環境裏面。

1.exp 導出:

exp health_base/[email protected]:11521/orcl owner=('health_base') rows=y indexes=y feedback=100000 file=D:\health_base/health_base%Date:~0,4%%Date:~5,2%%Date:~8,2%%Time:~0,2%%Time:~3,2%%Time:~6,2%.dmp log=D:\health_base\health_base%Date:~0,4%%Date:~5,2%%Date:~8,2%%Time:~0,2%%Time:~3,2%%Time:~6,2%.log 

--owner=('health_base') 導出用戶 D:\health_base 需要創建目錄
--這裏是遠程導出
 

也可以遠plsql 導出。或者直接在數據庫服務器上導出等。

  

通過exp/imp 方式導出導入 。一定要明確原有數據庫導出使用的用戶,表空間,以及使用的臨時表空間。

select * from dba_users where username='HEALTH_BASE'; --切記這個地方username 是大寫

 

查詢效果如下

2.select f.file#,t.ts#,f.name "File",t.name "Tablespace"
     from v$tempfile f,V$tablespace t
      where f.ts# = t.ts#
    --查詢臨時表空間

查詢效果如下

3.綜合上面2中查詢情況我們可以明確 heath_base 用戶 使用的默認表空間是Health_BASE。臨時表空間名稱是Health_BASE_TEMP

 

4.腳本:以系統管理員賬號登錄 我這裏以system 

切記切記:datafile 目錄查看下當前目錄對應掛載磁盤空間。


create tablespace health_base
logging
datafile '/data/oracle/oradata/health_base.dbf'
size 1000m
autoextend on
next 128m maxsize UNLIMITED
extent management local;

alter tablespace health_base
add datafile '/data/oracle/oradata/health_base2.dbf'
size 1000M
autoextend on
next 128m maxsize UNLIMITED;

alter tablespace health_base
add datafile '/data/oracle/oradata/health_base3.dbf'
size 1000M
autoextend on
next 128m maxsize UNLIMITED;

create temporary tablespace  health_base_temp
 TEMPFILE '/data/oracle/oradata/health_base_temp.DBF' 
 SIZE 512M REUSE AUTOEXTEND ON NEXT  1M MAXSIZE UNLIMITED;

create user health_base identified by health_base
default tablespace health_base
temporary tablespace health_base_temp;
 
 
grant connect,resource,dba to health_base; --按照實際情況分配權限

5遠程導入

imp health_base/[email protected]:11521/orcl  fromuser=health_base touser=health_base file=D:\health_base\health_base.dmp ignore=y  feedback=100000 buffer=10240000 log=D:\health_base\loghealth_base.log 

後續講expdb/impdb  垮用戶,表空間,臨時表空間的導入導出。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章