1:如果要導入的用戶下有空表,需要執行下面語句
select 'alter table '||table_name||' allocate extent;' from user_tables where num_rows=0
查詢出的數據拷出來,再次執行
2:cmd進入命令,導出
-
導出用戶所有的表到D盤: exp aa/1234 file=D:\biao.dmp owner=aa;
-
-
導出用戶aa中的表dept到D盤: exp aa/1234 file=d:\dept.dmp tables=(dept);
-
-
導出用戶aa中的表dept,emp到D盤: exp aa/1234 file=d:\dept.dmp tables=(dept,emp);
3:刪除原有用戶
-
在cmd中輸入
-
sqlplus / as sysdba
drop user aa cascade
4:創建用戶
-
create user aa identified by 1234;(aa:用戶名,1234:密碼)
-
-
grant dba,connect to aa;-----授權
5:導入
-
將D盤的biao.dmp導入到用戶bb中:
-
imp aa/ 1234 file=d:\biao.dmp full=y
-
-
將用戶aa中表dept中的數據導入到用戶bb的dept表中:
-
imp bb/ 1234 file=d:\dept.dmp tables=(dept) ignore=y full=y
總結:
-
exp smart/smart file=D:\smart.dmp owner=smart;
-
drop user smart cascade;
-
create user smart identified by smart;
-
grant dba,connect to smart;
-