zoukankan      html  css  js  c++  java
  • 如何将dmp文件导入到Oracle

    一、概述

      在将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:UsersxiejiachenDesktop est20190630.DMP" full =y;

      使用server_name的导入方式如下:

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

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

     

  • 相关阅读:
    分数拆分
    thinkphp URL规则、URL伪静态、URL路由、URL重写、URL生成(十五)
    iOS_12_tableViewCell的删除更新_红楼梦
    关于0基础磁盘管理(gpt UEFI...)最好的一篇文章(来自gentoo linux)
    HDU 3564 Another LIS splay(水
    jsp表达式
    XML(四)dom4j解析XML
    Android学习笔记(十八)——使用意图筛选器和实现浏览网页(附源代码)
    Oracle企业管理框架
    em grid control网格控制
  • 原文地址:https://www.cnblogs.com/chhyan-dream/p/12158506.html
Copyright © 2011-2022 走看看