Oracle 汇入汇出表空间跟资料表通用操作笔记

1:如果要汇入的使用者下有空表,需要执行下面语句
select 'alter table '||table_name||' allocate extent;' from user_tables where num_rows=0
查询出的资料拷出来,再次执行
2:cmd进入命令,汇出
汇出使用者所有的表到D盘:exp aa/1234 file=D:iao.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:iao.dmp full=y
imp whjyj/whjyj file=d:ckprojectwhjyjiao.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 whjyj cascade;
create user smart identified by smart;
grant dba,connect to smart;
imp smart/smart file=d:smart.dmp full=y;
select * from all_tables where owner='whjyj' 检视当前使用者所有表
drop user user_name cascade;删除使用者以及表资料
create tablespace whjyj datafile ‘E:appAdministratorwhjyj.dbf’ size 100M; 建立表空间
create user whjyj identified by whjyj default tablespace whjyj; 建立使用者并且分配表空间
grant dba,connect to whjyj; 授权