oracle下導出某用戶所有表的方法
scott/tiger是用戶名和密碼,handson是導出的實例名
² 按用戶方式導出數(shù)據(jù)(owner當中寫的是用戶名)
exp scott/tiger@handson file=scott_back owner=scott
² 按表方式導出數(shù)據(jù)(talbes當中寫的是全部表的名稱)
exp scott/tiger@handson tables=(emp, dept) file=scott_back_tab
² 按表空間方式導出數(shù)據(jù)(tablespaces當中寫的是表空間名稱)
exp system/handson@handson tablespaces=(users) file=tbs_users
² 使用參數(shù)文件導出數(shù)據(jù)
exp system/handson parfile='C:\parameters.txt
1、cmd->exp->username/passwd@sid-->.....一路回車--->輸入導出庫得名字 就把所有的表、視圖、存儲過程、函數(shù)、作業(yè)等亂七八糟的都導出來了;
2、pl/sql-->工具---〉導出用戶對象 可以找到你要導的東東。
兩者都可以的很方便!
導出表: exp scott/tiger@mycon tables=(dept,emp) file=tab1.dmp
導出用戶: exp system/manager@mycon owner=scott file=usr1.dmp
導出數(shù)據(jù)庫:
1.完全導出 exp system/manager@mycon full=y inctype=complete file=full1.dmp
2.增量導出 exp system/manager@mycon full=y inctype=incremental file=inc1.dmp
3.累積導出 exp system/manager@mycon full=y inctype=cumulative file=cum1.dmp
導入表: imp system/manager@mycon file=c:\tab1.dmp tables=(dept,emp) touser=scott
導入用戶: imp system/manager@mycon file=usr1.dmp fromuser=scott touser=scott
導入數(shù)據(jù)庫:
1.全庫導入 imp system/manager@mycon file=full1.dmp full=y
2.增量導入
1)導入數(shù)據(jù)庫最新信息 imp system/manager@mycon inctype=system full=y file=inc7.dmp 2)導入最近完全導出文件 imp system/manager@mycon inctype=restore full=y file=full1.dmp
3)導入所有累積導出文件 imp system/manager@mycon inctype=restore full=y file=cum1.dmp
4)導入最近一次增量導出的文件 imp system/manager@mycon inctype=restore full=y file=inc1.dmp
常用的命令
Exp user/password@instance file=file.dmp rows=y log=log_name
其中username/password為導出用戶的用戶名和密碼
Instance為導出的實例名
Rows是指定是否要導入表中的行
導出一個用戶下的表結(jié)構(gòu)為sql文件:
使用命令好像導出的都是dmp文件
可以使用plsql軟件在tools--àexport user object
如果不要到處table space ,不要勾include storage
選擇導出的路徑文件名,export可以直接導出了
例子1:(本方法限oracle9i版本以上)
set pagesize 0
set long 90000
set feedback off
set echo off
spool get_allddl.sql
connect USERNAME/PASSWORD@SID;
SELECT DBMS_METADATA.GET_DDL('TABLE',u.table_name)
FROM USER_TABLES u;
SELECT DBMS_METADATA.GET_DDL('INDEX',u.index_name)
FROM USER_INDEXES u;
spool off;
例子2:
首先在sqlplus下以該用戶登錄到oracle數(shù)據(jù)庫,然后將以下內(nèi)容粘貼到sqlplus中:
set feedback off;
set pagesize 0;
set heading off;
set verify off;
set linesize 200;
set trimspool on;
spool c:\數(shù)據(jù)庫備份.bat;
select 'exp username/ffffff@yourdb TABLES='||table_name||' FILE='||table_name||'.dmp TRIGGERS=N' from user_tables;
spool off;
set feedback on;
set pagesize 9999;
set heading on;
set verify on;
exit
完成后在找到 c:\數(shù)據(jù)庫備份.bat 文件,編輯該批處理文件,將第一行和最后一行刪掉,保存后運行該批處理文件就可全部導出該用戶下的所有表。
oracle下導入某用戶所有表的方法
² 將整個文件導入數(shù)據(jù)庫
imp system/handson@handosn file=item_back.dmp ignore=y full=y
² 將scott用戶的表導入到martin用戶
imp system/handson@handosn file=scott_back fromuser=scott touser=martin tables=(emp,dept)
² 使用參數(shù)文件導入數(shù)據(jù)
imp system/oracle parfile='C:\parameters.txt
常用命令
Imp username/password file=file.dmp fromuser=user1 touser=user2 rows=y
其中username/password為導入到數(shù)據(jù)庫的用戶名和密碼
Fromuser為備份數(shù)據(jù)庫時的用戶
Touser為導入數(shù)據(jù)庫的用戶,一般和username同