expdp/impdp数据泵方式备份还原数据库
1、用sysdba账号登入数据库,然后查询到要更改的用户信息: SELECT user#,name FROM user$ where user#=110; 2、更改用户名并提交: UPDATE USER$ SET NAME='C##DALIAN' WHERE user#=110; COMMIT; 3、强制刷新: ALTER SYSTEM CHECKPOINT; ALTER SYSTEM FLUSH SHARED_POOL; 4、更新用户的密码: ALTER USER c##yk_dalian_test IDENTIFIED BY Letmein_12#$; # 查询需要修改的用户 SELECT user#,name FROM user$ where user#=110; # 创建备份路径,expdp/impdp必须要有这个地址 create directory dumpdir as '/home/oracle' # 导出数据库 expdp 'C##DALIAN/Letmein' directory=DUMPDIR schemas=C##DALIAN dumpfile=2021_shujuku.dmp logfile=shujuku.log # 删除表空间 drop user c##yk_dalian_test cascade; # 创建表空间 create tablespace c##yk_dalian_test datafile '/orc/app/oracle/oradata/orcl/c##yk_dalian_test.dbf' size 500M autoextend on next 5M maxsize unlimited; # 创建用户并指定表空间 create user c##yk_dalian_test identified by Letmein_12#$ default tablespace c##yk_dalian_test temporary tablespace temp profile default; # 用户授权 grant connect,resource,dba to c##yk_dalian_test; # 还原数据库。 remap_schema修改用户名, remap_tablespace修改表空间 impdp c##yk_dalian_test/Letmein_12#$ DIRECTORY=DUMPDIR dumpfile=2021_shujuku.dmp remap_schema=C##DALIAN:c##yk_dalian_test remap_tablespace=C##DALIAN:c##yk_dalian_test # 查询指定用户表空间 select default_tablespace from dba_users where username='c##yk_dalian_test';
1、用sysdba账号登入数据库,然后查询到要更改的用户信息:
SELECT user#,name FROM user$ where user#=110;
2、更改用户名并提交:
UPDATE USER$ SET NAME='C##DALIAN' WHERE user#=110;
COMMIT;
3、强制刷新:
ALTER SYSTEM CHECKPOINT;
ALTER SYSTEM FLUSH SHARED_POOL;
4、更新用户的密码:
ALTER USER c##yk_dalian_test IDENTIFIED BY Letmein_12#$;
# 查询需要修改的用户
SELECT user#,name FROM user$ where user#=110;
# 创建备份路径,expdp/impdp必须要有这个地址
create directory dumpdir as '/home/oracle'
# 导出数据库
expdp 'C##DALIAN/Letmein' directory=DUMPDIR schemas=C##DALIAN dumpfile=2021_shujuku.dmp logfile=shujuku.log
# 删除表空间
drop user c##yk_dalian_test cascade;
# 创建表空间
create tablespace c##yk_dalian_test datafile '/orc/app/oracle/oradata/orcl/c##yk_dalian_test.dbf' size 500M autoextend on next 5M maxsize unlimited;
# 创建用户并指定表空间
create user c##yk_dalian_test identified by Letmein_12#$ default tablespace c##yk_dalian_test temporary tablespace temp profile default;
# 用户授权
grant connect,resource,dba to c##yk_dalian_test;
# 还原数据库。 remap_schema修改用户名, remap_tablespace修改表空间
impdp c##yk_dalian_test/Letmein_12#$ DIRECTORY=DUMPDIR dumpfile=2021_shujuku.dmp remap_schema=C##DALIAN:c##yk_dalian_test remap_tablespace=C##DALIAN:c##yk_dalian_test
# 查询指定用户表空间
select default_tablespace from dba_users where username='c##yk_dalian_test';