好长时间没有用过Oracle了,突然之间一用,导库发现少好多表,明明已经全导出了,问题出在什么地方.....
经过查看资料,原因是11G中有个新特性,当表无数据时,不分配segment,以节省空间,只需要在空表中添加一条数据在删除,就会产生segment。导出时则可导出空表。 接下来跟着我去尝试一下吧
1、先查看哪些表是空表
select table_name from user_tables where NUM_ROWS=0;
2、拼接字符串生成SQL语句
select 'alter table '||table_name||' allocate extent;' from user_tables where num_rows=0 ;
3、然后把复制到的SQL语句去执行一下
4、最后就是导出数据库了
5、导出数据库
步骤一:打开cmd;
步骤二:语法: exp 用户名/密码@服务名 tables=表名 file=存入本地dmp目标地址 log=存入本地log目标地址 owner=要导出的用户名
导出表:exp test/test@orcl tables=sys_user file=D:/user.dmp log=D:/user.log
导出数据库:去掉“ tables=表名 “ 就好!
exp test/test@orcl file=D:/user.dmp log=D:/user.log
导出该用户的数据库 :
exp test/test@orcl file=D:/user.dmp log=D:/user.log owner=test
6、导入数据库
步骤一:打开cmd;
步骤二:输入:imp 用户名/密码 BUFFER=64000 file=数据库表.dmp存放的地址 ignore=y full=y
说明:ignore=y是表示忽略创建错误,继续后面的操作;full=y表示导入文件中的全部内容,有可能有多个用户的内容,如果你链接的用户默认使用的表空间设置是system,则导入文件的内容会导到system上。
示例:imp test/test BUFFER=64000 file=D:/user.dmp ignore=y full=y
或
imp test/test@127.0.0.1:1521/orcl file=D:\user.dmp ignore=y log=D:\user.log fromuser = test1 touser = test statistics=none