oracle数据库备份与还原完整版

--切换数据库角色
su - orcale
--创建表空间
create tablespace TESTSIT 
datafile '/data/oracle/oradata/TESTSIT.DBF' 
size 128m 
autoextend on 
next 
50m maxsize unlimited;

create tablespace NNC_DATA01 
datafile '/data/oracle/oradata/NNC_DATA01.DBF' 
size 128m 
autoextend on 
next 
50m maxsize unlimited;

--创建用户
create user test identified by test
default tablespace TESTSIT 
temporary tablespace TEMP
profile DEFAULT;

--赋权
GRANT "DBA" TO "test";
grant connect to test;
grant resource to test;
grant create database link to test;
grant create job to test;
grant create procedure to test;
grant create public database link to test;
grant create synonym to test;
grant create table to test;
grant create view to test;
grant debug connect session to test;
grant select any dictionary to test;
grant unlimited tablespace to test;


--创建备份文件夹
drop directory kmdata_exp ;
create or replace directory kmdata_exp as '/data/oracle/backup';

grant read,write on directory kmdata_exp to public ;
mkdir /data/oracle/backup;
chown -R oracle:oinstall /data/oracle/backup;
--查看源数据库文件编码
select * from v$nls_parameters where parameter='NLS_CHARACTERSET';

--如果编码不一致,可修改待客户端编码(先备份)
SQL> conn /as sysdba
SQL> shutdown immediate; 
SQL> startup mount 
SQL> ALTER SYSTEM ENABLE RESTRICTED SESSION; 
SQL> ALTER SYSTEM SET JOB_QUEUE_PROCESSES=0; 
SQL> ALTER SYSTEM SET AQ_TM_PROCESSES=0; 
SQL> alter database open; 
SQL> ALTER DATABASE character set INTERNAL_USE AL32UTF8;

--修改完毕后,再重新启动
SQL> select * from v$nls_parameters;  
SQL> shutdown immediate; 
SQL> startup 
SQL> select * from v$nls_parameters; 

--导入备份数据库
--数据和索引分开导入
impdp test/test directory=kmdata_exp table_exists_action=truncate dumpfile=back-0114.dmp logfile=expdp.log ignore=y exclude=index exclude=constraint version=19.0.0.0.0
impdp test/test directory=kmdata_exp table_exists_action=truncate dumpfile=back-0114.dmp logfile=expdp.log ignore=y include=index include=constraint version=19.0.0.0.0
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值