oracle如何通過cmd導出某個用戶下的所有表


1:如果要導入的用戶下有空表,需要執行下面語句

select 'alter table '||table_name||' allocate extent;' from user_tables where num_rows=0

查詢出的數據拷出來,再次執行

2:cmd進入命令,導出

  1.  
    導出用戶所有的表到D盤: exp aa/1234 file=D:\biao.dmp owner=aa;
  2.  
     
  3.  
    導出用戶aa中的表dept到D盤: exp aa/1234 file=d:\dept.dmp tables=(dept);
  4.  
     
  5.  
    導出用戶aa中的表dept,emp到D盤: exp aa/1234 file=d:\dept.dmp tables=(dept,emp);

3:刪除原有用戶

  1.  
    在cmd中輸入
  2.  
    sqlplus / as sysdba
 drop user aa cascade

4:創建用戶

  1.  
    create user aa identified by 1234;(aa:用戶名,1234:密碼)
  2.  
     
  3.  
    grant dba,connect to aa;-----授權

5:導入

  1.  
    將D盤的biao.dmp導入到用戶bb中:
  2.  
    imp aa/ 1234 file=d:\biao.dmp full=y
  3.  
     
  4.  
    將用戶aa中表dept中的數據導入到用戶bb的dept表中:
  5.  
    imp bb/ 1234 file=d:\dept.dmp tables=(dept) ignore=y full=y

總結:

  1.  
    exp smart/smart file=D:\smart.dmp owner=smart;
  2.  
    drop user smart cascade;
  3.  
    create user smart identified by smart;
  4.  
    grant dba,connect to smart;
  5.  
    imp smart/smart file=d:\smart.dmp full=y;
     
     
    ===================================

    select * from dba_users; 查看數據庫里面所有用戶,前提是你是有dba權限的帳號,如sys,system

    select * from all_users;  查看你能管理的所有用戶!

    select * from user_users; 查看當前用戶信息 !

     

     


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM