oracle備份和還原數據庫

導出(備份)命令 使用expdp/impdp命令須要先建立邏輯目錄 sql

使用命令登陸oracle:sqlplus 用戶名/密碼@XXXXsession

例如:sqlplus www/www@orcloracle

建立邏輯目錄,該命令不會在操做系統建立真正的目錄,最好以system等管理員建立。 app

create directory dpdata1 as 'd:\test\dump';

按用戶導ide

expdp scott/tiger@orcl schemas=scott dumpfile=expdp.dmp DIRECTORY=dpdata1

 

還原數據
1)導到指定用戶下spa

impdp scott/tiger DIRECTORY=dpdata1 DUMPFILE=expdp.dmp SCHEMAS=scott
impdp user/password directory=dpdir dumpfile=Logontab.dmp table_exists_action=replace 
logfile=implogontab.log

able_exists_action選項:{skip 是若是已存在表,則跳過並處理下一個對象;append是爲表增長數據;truncate是截斷表,而後爲其增長新數據;replace是刪除已存在表,從新建表並追加數據}操作系統

建立表空間.net

create tablespace TBS_OTHERS datafile 'G:\APP\ORCL\ORADATA\ORCL\TBS_OTHERS01.dbf' size 1000m;


-- 建立用戶code

create user C##JHGL identified by jhgl default tablespace TBS_OTHERS
create user C##YJYJHGL identified by jhgl default tablespace TBS_OTHERS
create user C##WCJHGL identified by jhgl default tablespace TBS_OTHERS
grant dba,resource,connect to C##JHGL,C##YJYJHGL,C##WCJHGL
grant dba,resource,connect to C##WCJHGL

--刪除session對象

--查詢session對應的sid,serial#
select saddr,sid,serial#,paddr,username,status from v$session where username is not null;
--kill session
alter system kill session 'sid,serial#' ;
相關文章
相關標籤/搜索