利用windows的cmd命令备份导出数据(也可以连接上sqlplus进行操作)
–导出
–将数据库orcl完全导出
exp system/oracle@orcl file=c:\oracle_bak\orcl_bak.dmp full=y
–将数据库中scott用户的所有对象导出
exp scott/tiger1@orcl file=c:\oracle_bak\scott_bak.dmp owner=scott
–将scott用户中表emp,dept导出
exp scott/tiger1@orcl file=c:\oracle_bak\table_bak.dmp tables=(emp,dept)
–导入
–将备份文件导入到数据库
imp scott/tiger1@orcl file=c:\oracle_bak\scott_bak.dmp ignore=y
–将scott用户的备份文件导入到yanln用户中
imp yanln/yanln@orcl fromuser=scott touser=yanln file=c:\oracle_bak\scott_bak.dmp
–创建员工表的备份表
create table emp_bak
as
select * from emp;
–创建触发器来实现数据的同步备份
–当删除员工后,备份表同步删除
create or replace trigger syno_bak_trigger
after delete
on emp
for each row
begin
delete from emp_bak where empno = :old.empno;
end;
–测试
select * from emp;
delete from emp where empno = 7499;
select * from emp_bak;
rollback;
此外还可以利用pl/sql developer工具进行导出和导入