oracle dmp 导入 mysql_如何将dmp文件导入到Oracle

本文详细介绍了如何在Oracle数据库中创建用户、设置表空间,并解决在Oracle 19c中创建用户时遇到的“ORA-65096”错误。此外,还提供了使用IMP命令导入DMP文件的方法,包括通过Server_id和Server_name两种方式的导入示例。
摘要由CSDN通过智能技术生成

一、概述

在将dmp文件导入到Oracle中之前,需要先创建一个orcale用户。然后使用该用户名和密码,以imp的方式将数据导入到oracle中。

二、执行步骤

1、登陆oracle数据库

sqlplus / as sysdba

2、查询临时空间表和表空间的存储位置

select name from v$tempfile;

429bfcdd225d7ed6ad6127d333424ed7.png

select name from v$datafile;

e4bb996ac6d19d3c6f7e8ff6a5c2fffb.png

3、创建用户临时表空间和表空间,使用上面查到的任一存储位置即可

create temporary tablespace demo_temp tempfile ‘/oracle/u02/oradata/ERP2/demo_temp.dbf‘ size 100m reuse autoextend on next 20m maxsize unlimited;

create tablespace demo datafile ‘/oracle/u02/oradata/ERP2/demo.dbf‘ size 100M reuse autoextend on next 40M maxsize unlimited default storage(initial 128k next 128k minextents 2 maxextents unlimited);

注:删除表空间的命令drop   tablespace   temp   including   contents   and   datafiles;4、创建用户并指定表空间

create user demo identified by demo default tablespace demo temporary tablespace demo_temp;

4、如果此时报错,Oracle 19c:创建用户时出现“ORA-65096: invalid common user or role name”的错误

这时涉及到CDB和PDB的基本管理,资料来源oracle官方。

基本概念:

Multitenant Environment:多租户环境

CDB(Container Database):数据库容器

PD(Pluggable Database):可插拔数据库

CDB与PDB关系图

COMMON USERS(普通用户):经常建立在CDB层,用户名以C##或c##开头;

LOCAL USERS(本地用户):仅建立在PDB层,建立的时候得指定CONTAINER。

5670d48e5637af2fa8fcb603d9ad0210.png

官方原始文件介绍如下:

The data dictionary in each container in a CDB is separate, and the current container is the container whose data dictionary is used for name resolution and for privilege authorization. The current container can be the root or a PDB. Each session has exactly one current container at any point in time, but it is possible for a session to switch from one container to another.

Each container has a unique ID and name in a CDB. You can use the CON_ID and CON_NAME parameters in the USERENV namespace to determine the current container ID and name with the SYS_CONTEXT function.

说白了,就是你当前的session不能创建你需要的用户,需要使用SYS_CONTEXT函数

a、查看Oracle 19c的版本

select * from v$version;

59fb8c83873c7ea3da486bc11330d2db.png

select sys_context (‘USERENV‘, ‘CON_NAME‘) from dual;

b、我们可以通过ALTER SESSION SET CONTAINER 指定其他容器

select con_id,dbid,NAME,OPEN_MODE from v$pdbs;

C、将PDB open

alter pluggable database pdborcl open;

d、查看容器

select con_id,dbid,NAME,OPEN_MODE from v$pdbs;

e、切换到pdb

alter session set container=PDBORCL;

f、查看当前使用容器

select sys_context (‘USERENV‘, ‘CON_NAME‘) from dual;

g、创建用户

create user demo identified by demo default tablespace demo temporary tablespace demo_temp;

5、导入文件到oracle

oracle连接方式用两种,一般用户喜欢使用Server_id的方式,导入方式为

imp demo/[email protected] file="C:\Users\xiejiachen\Desktop\test20190630.DMP" full =y;

使用server_name的导入方式如下:

imp demo/[email protected]/ORCLpdb1 file=home/oracle/demo.dmp ignore=y full=y

其中demo为用户名,123456为密码,@后面是主机名称,ORCLpdb1是server的名称。

原文:https://www.cnblogs.com/chhyan-dream/p/12158506.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值