oracle如何备份数据库

1.创建表空间
sql命令:
create tablespace jeefh2_gblz17
logging
datafile ‘/u02/oradata/orcl/jeefh2_gblz17.dbf’ --表空间文件存储位置
size 1024m --表空间文件初始大小
autoextend on --表空间自动增长
next 100m maxsize unlimited --自动增长文件大小及最大空间
extent management local;

2.创建用户
sql命令:
create user jeefh2_gblz17 identified by jeefh2_gblz17
default tablespace jeefh2_gblz17
temporary tablespace temp;
3.给用户授予权限
sql命令:
grant connect,resource,dba to jeefh2_gblz17;
4.导出/导入表结构
oracle如何备份数据库_第1张图片
oracle如何备份数据库_第2张图片
5.导出/导入表数据(命令窗口执行)
sql命令:
exp jeefh_gblz_zd04/[email protected]:1521/orcl file=h:/jeefh_gblz_zd04_2019052300.dmp owner=“jeefh_gblz_zd04”

imp jeefh_gblz_zd06/[email protected]:1521/orcl file=h:/jeefh_gblz_zd04_2019052300.dmp fromuser=‘jeefh_gblz_zd04’ touser=‘jeefh_gblz_zd06’ data_only=y

注意:
–查询当前用户有多少张表(表名)
select wm_concat(object_name) from user_objects where lower(object_type)=‘table’;

–如果导入到一半报错,剩余的按表名接着导入
imp jeefh2_gblz18/[email protected]:1521/orcl file=h:/jeefh2_gblz12_2019031800.dmp data_only=y tables=(T_MONTH_WORK_REAL_C_NORM,T_PUB_MESSAGE)

注意:大家在导入表数据前最好先把触发器禁用掉,导入之后再启用!

你可能感兴趣的:(java基础,数据库)