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#' ;
相关文章
相关标签/搜索