oracle备份

1: 用sys/orcl登陆:

oracle备份_第1张图片

2:创建用户(PLSQL Developer) :
create tablespace tianbao datafile 'F:\app\liuwentao\tablespace\tianbao01.dbf' size 100m;
create tablespace tianbao_index datafile 'F:\app\liuwentao\tablespace\tianbao_index01.dbf' size 100m;  
create user tianbao identified by tianbao default tablespace tianbao;  
grant connect,resource,dba to tianbao;
alter user tianbao quota unlimited on tianbao_index; 


删除用户
drop user newtrans cascade;   
drop tablespace newtrans including contents 
drop tablespace newtrans_index including contents 


修改表空间
ALTER DATABASE DATAFILE 'D:\yd888\liuwentao\oracle\tablespace\xueci201.dbf' AUTOEXTEND ON NEXT 100M MAXSIZE UNLIMITED
ALTER DATABASE DATAFILE 'D:\yd888\liuwentao\oracle\tablespace\xueci2_index01.dbf' AUTOEXTEND ON NEXT 100M MAXSIZE UNLIMITED


3:导出(命令窗口):
exp tianbao/tianbao@orcl file=c:\tianbao_1130.dmp log=c:\tianbao_1130_exp.log rows=y statistics=none 

oracle备份_第2张图片

4:导入(命令窗口):
imp tianbao/tianbao@orcl2011 fromuser=tianbao touser=tianbao file=c:\tianbao_1130.dmp log=c:\tianbao_1130_imp.log

oracle备份_第3张图片

一.说明
   oracle 的exp/imp命令用于实现对数据库的导出/导入操作;
   exp命令用于把数据从远程数据库服务器导出至本地,生成dmp文件;
   imp命令用于把本地的数据库dmp文件从本地导入到远程的Oracle数据库中。

二.使用示例

1 数据导出:

1.1 将数据库SampleDB完全导出,用户名system 密码manager 导出到E:/SampleDB.dmp中
  
exp system/manager@TestDB file=E:/sampleDB.dmp full=y

1.2 将数据库中system用户与sys用户的表导出
  
exp system/manager@TestDB file=E:/sampleDB.dmp  owner=(system,sys)

1.3 将数据库中的表 TableA,TableB 导出
   
exp system/manager@TestDB  file=E:/sampleDB.dmp  tables=(TableA,TableB)

1.4 将数据库中的表tableA中的字段filed1 值为 "王五" 的数据导出
  
exp system/manager@TestDB  file=E:/sampleDB.dmp  tables=(tableA)  query=“ where filed1='王五'”

2 数据的导入
  2.1 将备份数据库文件中的数据导入指定的数据库SampleDB 中,如果 SampleDB 已存在该表,则不再导入;
 
 imp system/manager@TEST  file=E:/sampleDB.dmp  full=y  ignore=y

  2.2 将d:/daochu.dmp中的表table1 导入
  
imp system/manager@TEST  file=E:/sampleDB.dmp  tables=(table1)

  2.3. 导入一个完整数据库
  
imp system/manager file=bible_db log=dible_db full=y ignore=y

  2.4. 导入一个或一组指定用户所属的全部表、索引和其他对象
 
 imp system/manager file=seapark log=seapark fromuser=seapark 
   imp system/manager file=seapark log=seapark fromuser=(seapark,amy,amyc,harold)

  2.5. 将一个用户所属的数据导入另一个用户
 
 imp system/manager file=tank log=tank fromuser=seapark touser=seapark_copy
   imp system/manager file=tank log=tank fromuser=(seapark,amy) touser=(seapark1, amy1)

  2.6. 导入一个表
  
imp system/manager file=tank log=tank fromuser=seapark TABLES=(a,b)

  2.7. 从多个文件导入
  
imp system/manager file=(paycheck_1,paycheck_2,paycheck_3,paycheck_4) log=paycheck, filesize=1G full=y

  2.8 增量导入
  
imp system./manager inctype= RECTORE FULL=Y  FILE=A

   不少情况下要先将表彻底删除,然后导入。


修改表空间路径:

1:
alter tablespace newcourse offline;
alter tablespace newcourse_index offline; 


2:copy d:\oracle to E:\oracle

3:
alter tablespace newcourse rename datafile 'D:\oracle\tablespace\newcourse01.dbf' to 'E:\oracle\tablespace\newcourse01.dbf';
alter tablespace newcourse_index rename datafile 'D:\oracle\tablespace\newcourse_index01.dbf' to 'E:\oracle\tablespace\newcourse_index01.dbf';


导入sequence
select dbms_metadata.get_ddl('SEQUENCE',u.object_name) from user_objects u where object_type='SEQUENCE'


oracle备份_第4张图片

再整理成sql 导入即可

你可能感兴趣的:(oracle,Security)