Oracle數據庫導出有4種模式:ful(全庫導出),owner(用戶導出),table(表導出),tablespace(表空間導出)。
1、數據常用導出命令
①將數據庫TEST完全導出,用戶名system密碼manager,導出到/tmp/daochu.dmp中
exp system/manager@TEST file=/tmp/daochu.dmp full=y (全庫導出)
exp xtjg_user/123456@ORCL file=/tmp/XTJG.dmp 默認導出連接數據庫的用戶數據庫對象
②將數據庫中system用戶和sys用戶的表導出
exp system/manager@TEST file=d:/daochu.dmp owner=(system,sys)
③將數據庫中的表table1 、table2導出
exp system/manager@TEST file=d:/daochu.dmp tables=(table1,table2)
④ 將數據庫中的表table1中的字段filed1以"00"打頭的數據導出
exp system/manager@TEST file=d:/daochu.dmp tables=(table1)query=/" where filed1 like '00%'/"
2、導入dmp命令
在導入dmp文件時候,通常我們需要新建一個用戶來導入,新用戶需要一個表空間和一個臨時表空間。
表空間是數據庫的邏輯劃分,一個表空間只能屬于一個數據庫。所有的數據庫對象都存放在指定的表空間中。但主要存放的是表,所以稱作表空間。Oracle臨時表空間主要用來做查詢和存放一些緩沖區數據。臨時表空間,可自動釋放;而表空間中存儲表數據、函數、過程、序列等。是隨數據庫永久存在的。
新建臨時表空間:
create temporary tablespace user_temp
tempfile '/usr/local/oradata/orcl/user_temp.dbf'
size 50m
autoextend on
next 50m maxsize 20480m
extent management local;
新建表空間:
create tablespace xtjg
logging
datafile '/usr/local/oradata/orcl/xtjg.dbf'
size 50m
autoextend on ;
新建用戶:
create user xtjg_user identified by 123456
default tablespace xtjg
temporary tablespace user_temp;
授權新用戶:
grant connect,resource to user_name;
grand dba to user_name;
導入dmp文件:
imp user_name/user_passWord@SID file=F:/xxx.dmp full=y;
如:imp xtjg_user/123456@orcl file=/home/software/XTJG.dmp full=y;
備注:
1、關于full=y參數
①oracle exp命令中的full參數
full=y(全庫導出): 導出除ORDSYS,MDSYS,CTXSYS,ORDPLUGINS,LBACSYS這些系統用戶之外的所有用戶的數據.
full=n或不加full:默認導出連接數據庫的用戶數據庫對象.
②oracle imp命令中的full參數
Full=y 導入一個完整的數據庫
2、刪除命令
刪除用戶:
drop user user_name cascade;
刪除表空間和臨時表空間:
drop tablespace tablespace_name including contents;
新聞熱點
疑難解答