zoukankan      html  css  js  c++  java
  • Oracle利用数据泵迁移用户

    一.利用数据泵将数据导出

    1.1.确定字符集:

    select * from v$nls_parameters;

    select userenv('language') from dual;

    1.2.设置客户端字符集(Windows)

    set NLS_LANG = NLS_LANGUAGE_NLS_TERRITORY.NLS_CHARACTERSET

    或 linux

    export NLS_LANG=AMERICAN_AMERICA.AL32UTF8

    1.3.确定schema的对象所占用表空间

    SQL> Select distinct segment_type,tablespace_name 
    SQL> From dba_segments 
    SQL> Where owner='NC2010';
    
    SEGMENT_TYPE       TABLESPACE_NAME
    ------------------ ------------------------------
    TABLE              NNC_DATA03
    TABLE              NNC_DATA02
    LOBSEGMENT         NNC_DATA01
    INDEX              NNC_INDEX01
    INDEX              NNC_DATA01
    INDEX              NNC_INDEX02
    TABLE              NNC_DATA01
    LOBINDEX           NNC_DATA01
    INDEX              NNC_INDEX03
    
    9 rows selected.
    
    SQL>

    1.4 查看用户默认表空间

    select username,default_tablespace from user_users;

    1.5.用数据泵导出数据

    --创建directory 并赋权
    SQL> conn / as sysdba;
    SQL> create directory backup as 'e:ackup';
    SQL> grant read,write on directory backup to NC60;
    SQL> select * from dba_directories
    
    --导出schema
    [oracle@localhost ~]$ expdp nc60/nc60 DIRECTORY=backup DUMPFILE=tianlesoftware.dmp SCHEMAS=NC60 logfile=exp.log;
    
    --注,如果源库与目的库oracle版本不同,导出时需指定version参数。

    二.将dump文件导入RAC或单实例

    2.1 确定字符集

    select userenv('language') from dual;

    2.2 设置客户端字符集(linux)

    export NLS_LANG = NLS_LANGUAGE_NLS_TERRITORY.NLS_CHARACTERSET

    2.3 检查RAC运行状态

    2.4 创建相关用户和表空间

    --查看数据文件
    select file_name from dba_data_files;
    
    --创建表空间(与1.3查询结果相同)
    --SQL> create tablespace NNC_DATA01  datafile '+DATA/orcl/datafile/tianlesoftware.dbf' size 50m;
    --SQL> create tablespace NNC_DATA02  datafile '+DATA/orcl/datafile/tianlesoftware.dbf' size 50m;
    --SQL> create tablespace NNC_DATA03  datafile '+DATA/orcl/datafile/tianlesoftware.dbf' size 50m;
    
    --SQL> create tablespace NNC_INDEX01 datafile '+DATA/orcl/datafile/tianlesoftware.dbf' size 50m;
    --SQL> create tablespace NNC_INDEX02 datafile '+DATA/orcl/datafile/tianlesoftware.dbf' size 50m;
    --SQL> create tablespace NNC_INDEX03 datafile '+DATA/orcl/datafile/tianlesoftware.dbf' size 50m;
    
    --创建用户
    SQL> create user NC60 identified by NC60 default tablespace NNC_DATA01 temporary tablespace temp;
    
    
    --赋予权限
    Grant resource,connect,dba to NC60;

    2.5 创建导入directory

    SQL> create directory backup as '/backup';

    SQL> Grant read,write on directory backup to NC60;

    2.6 导入数据

    [oracle@rac1 u01]$ export ORACLE_SID=orcl1

    [oracle@rac1 u01]$ impdp nc60/nc60 DIRECTORY=BACKUP DUMPFILE=NC60.dmp SCHEMAS=NC60 logfile=impdp.log;

    注,如果源库与目的库oracle版本不同,导入时需指定version参数。

  • 相关阅读:
    LeetCode 230. 二叉搜索树中第K小的元素(Kth Smallest Element in a BST)
    LeetCode 216. 组合总和 III(Combination Sum III)
    LeetCode 179. 最大数(Largest Number)
    LeetCode 199. 二叉树的右视图(Binary Tree Right Side View)
    LeetCode 114. 二叉树展开为链表(Flatten Binary Tree to Linked List)
    LeetCode 106. 从中序与后序遍历序列构造二叉树(Construct Binary Tree from Inorder and Postorder Traversal)
    指针变量、普通变量、内存和地址的全面对比
    MiZ702学习笔记8——让MiZ702变身PC的方法
    你可能不知道的,定义,声明,初始化
    原创zynq文章整理(MiZ702教程+例程)
  • 原文地址:https://www.cnblogs.com/polestar/p/4212473.html
Copyright © 2011-2022 走看看