Oracle 创建用户,数据泵导入导出

1.连接数据库

# sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Tue Dec 22 10:54:12 2020

Copyright (c) 1982, 2013, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> 

2.数据库正常,先确定表空间名、表空间剩余空间 

--查看剩余表空间大小
SELECT tablespace_name 表空间,sum(blocks*8192/1000000) 剩余空间M FROM dba_free_space GROUP BY tablespace_name;

3.创建用户

-- Create the user 
create user user_name identified by "user_password" default tablespace tablespace_name temporary tablespace TEMP profile DEFAULT;
--user_name 用户名,user_password 密码,tablespace_name 表空间名

--grant user 授权
grant connect to user_name ;
grant datapump_exp_full_database to user_name;
grant datapump_imp_full_database to user_name;
grant dba to user_name;
grant resource to user_name;
grant create view to user_name;
grant unlimited tablespace to user_name;

--drop user
drop user user_name cascade;

--ORA-01940错误,删除进程
select sid, serial# from v$session where username = 'user_name';
alter system kill session '195,531';

4.查询 directory_name、directory_path

--oracle查询directory_path
select * from all_directories;

5.放入导出DMP、LOG文件到directory_path 路径下

--复制DMP文件
cp -rf /dbbackup/histdata/202011/70_OA_11gXD_20201129.DMP /oracle/dbbackup

6.退出sqlplus,导入命令

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
--使用sysdba 权限导入,避免权限的问题
impdp \'/ as sysdba\' directory=DUMP_DIR dumpfile=70_OA_11gXD_20201129.DMP remap_schema=旧用户名:新用户名

7.导出数据(备份)

expdp test/123456@127.0.0.1/orcl compression=all DIRECTORY=DUMP_DIR DUMPFILE=TESTDB20211119.DMP

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值