一、概述

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

二、执行步骤

1、登陆oracle数据库

a、sqlplus / as sysdba

b、如果使用a不成功,则使用  sqlplus demo/demo@localhost/ORCLpdb1的方式

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

 select name from v$tempfile;

 

 select name from v$datafile;

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;

5、如果此时报错,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。

官方原始文件介绍如下:

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;

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;

6、导入文件到oracle

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

 imp demo/123456@orcl file="C:\Users\xiejiachen\Desktop\test20190630.DMP" full =y;

使用server_name的导入方式如下:

imp demo/123456@localhost/ORCLpdb1 file=home/oracle/demo.dmp ignore=y full=y

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

最新文章

  1. 《DSP using MATLAB》第6章开始了
  2. maven之helloworld案例
  3. SQL Server 2008 Datetime Cast 成 Date 类型可以使用索引(转载)
  4. 用happen-before规则重新审视DCL(转)
  5. 新贵HTML5,2016的发展方向会怎样?
  6. hdu 2711&&poj2182 Lost Cows (线段树)
  7. Android开发手记(11) 滑动条SeekBar
  8. FZU-1925+几何
  9. Node.mongoose
  10. test_CSDN_markdown_format
  11. spring boot 解决跨域访问
  12. JSAP106
  13. Angular4学习笔记(八)- ng-content
  14. jquery获取URL的参数和锚点
  15. ActiveMQ配置高可用性的方式
  16. T-SQL语句4
  17. 汉诺塔问题php解决
  18. hive介绍
  19. centos ntfs-3g 安装和使用
  20. python中的any和all函数

热门文章

  1. 反射工具类【ReflectionUtils】
  2. 分析一次double强转float的翻车原因(转载)
  3. 题解 AT1219 【歴史の研究】
  4. Java集合--线程安全(CopyOnWrite机制)
  5. A. Hotelier
  6. json object string互转
  7. jQuery Validation Engine(二) checkHello data-errormessage
  8. SpringBoot之Feign调用方式比较
  9. 「NOIP2016」愤怒的小鸟
  10. Link Analysis_1_Basic Elements