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:iao.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:iao.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; 查看当前用户信息 !

原文地址:https://www.cnblogs.com/YuyuanNo1/p/10607432.html